forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAliasedTupleSubsetResultTransformer.cs
42 lines (38 loc) · 1.16 KB
/
AliasedTupleSubsetResultTransformer.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
using System;
using System.Collections;
namespace NHibernate.Transform
{
/// <summary>
/// An implementation of TupleSubsetResultTransformer that ignores a
/// tuple element if its corresponding alias is null.
/// </summary>
/// @author Gail Badner
[Serializable]
public abstract class AliasedTupleSubsetResultTransformer : ITupleSubsetResultTransformer
{
public abstract bool IsTransformedValueATupleElement(string[] aliases, int tupleLength);
public bool[] IncludeInTransform(string[] aliases, int tupleLength)
{
if (aliases == null)
throw new ArgumentNullException("aliases");
if (aliases.Length != tupleLength)
{
throw new ArgumentException(
"aliases and tupleLength must have the same length; " +
"aliases.length=" + aliases.Length + "tupleLength=" + tupleLength
);
}
bool[] includeInTransform = new bool[tupleLength];
for (int i = 0; i < aliases.Length; i++)
{
if (aliases[i] != null)
{
includeInTransform[i] = true;
}
}
return includeInTransform;
}
public abstract object TransformTuple(object[] tuple, string[] aliases);
public abstract IList TransformList(IList collection);
}
}