forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAliasToEntityMapResultTransformer.cs
51 lines (44 loc) · 1.15 KB
/
AliasToEntityMapResultTransformer.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
using System;
using System.Collections;
namespace NHibernate.Transform
{
[Serializable]
public class AliasToEntityMapResultTransformer : AliasedTupleSubsetResultTransformer
{
internal static readonly AliasToEntityMapResultTransformer Instance = new AliasToEntityMapResultTransformer();
public override object TransformTuple(object[] tuple, string[] aliases)
{
IDictionary result = new Hashtable();
for (int i = 0; i < tuple.Length; i++)
{
string alias = aliases[i];
if (alias != null)
{
// TODO: Incredibly dodgy!! what if the user defines an alias ending in "_"
result[alias] = tuple[i];
}
}
return result;
}
public override IList TransformList(IList collection)
{
return collection;
}
public override bool IsTransformedValueATupleElement(string[] aliases, int tupleLength)
{
return false;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(obj, this))
return true;
if (obj == null)
return false;
return obj.GetType() == GetType();
}
public override int GetHashCode()
{
return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(Instance);
}
}
}