forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransformers.cs
58 lines (50 loc) · 2.57 KB
/
Transformers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.Collections;
namespace NHibernate.Transform
{
public static class Transformers
{
/// <summary>
/// Each row of results is a map (<see cref="IDictionary" />) from alias to values/entities
/// </summary>
public static readonly IResultTransformer AliasToEntityMap = AliasToEntityMapResultTransformer.Instance;
/// <summary> Each row of results is a <see cref="IList"/></summary>
public static readonly ToListResultTransformer ToList = ToListResultTransformer.Instance;
/// <summary>
/// Creates a result transformer that will inject aliased values into instances
/// of <paramref name="target"/> via property methods or fields.
/// </summary>
/// <param name="target">The type of the instances to build.</param>
/// <returns>A result transformer for supplied type.</returns>
/// <remarks>
/// Resolves setter for an alias with a heuristic: search among properties then fields for matching name and case, then,
/// if no matching property or field was found, retry with a case insensitive match. For members having the same name, it
/// sorts them by inheritance depth then by visibility from public to private, and takes those ranking first.
/// </remarks>
public static IResultTransformer AliasToBean(System.Type target)
{
return new AliasToBeanResultTransformer(target);
}
/// <summary>
/// Creates a result transformer that will inject aliased values into instances
/// of <typeparamref name="T"/> via property methods or fields.
/// </summary>
/// <typeparam name="T">The type of the instances to build.</typeparam>
/// <returns>A result transformer for supplied type.</returns>
/// <remarks>
/// Resolves setter for an alias with a heuristic: search among properties then fields for matching name and case, then,
/// if no matching property or field was found, retry with a case insensitive match. For members having the same name, it
/// sorts them by inheritance depth then by visibility from public to private, and takes those ranking first.
/// </remarks>
public static IResultTransformer AliasToBean<T>()
{
return AliasToBean(typeof(T));
}
public static readonly IResultTransformer DistinctRootEntity = DistinctRootEntityResultTransformer.Instance;
public static IResultTransformer AliasToBeanConstructor(System.Reflection.ConstructorInfo constructor)
{
return new AliasToBeanConstructorResultTransformer(constructor);
}
public static readonly IResultTransformer PassThrough = PassThroughResultTransformer.Instance;
public static readonly IResultTransformer RootEntity = RootEntityResultTransformer.Instance;
}
}