From: <fab...@us...> - 2011-05-20 14:32:04
|
Revision: 5842 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5842&view=rev Author: fabiomaulo Date: 2011-05-20 14:31:58 +0000 (Fri, 20 May 2011) Log Message: ----------- Minor (reformatted) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Linq/ResultTransformer.cs Modified: trunk/nhibernate/src/NHibernate/Linq/ResultTransformer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/ResultTransformer.cs 2011-05-20 13:58:52 UTC (rev 5841) +++ trunk/nhibernate/src/NHibernate/Linq/ResultTransformer.cs 2011-05-20 14:31:58 UTC (rev 5842) @@ -5,85 +5,86 @@ namespace NHibernate.Linq { - [Serializable] - public class ResultTransformer : IResultTransformer - { - private readonly Delegate _listTransformation; - private readonly Delegate _itemTransformation; + [Serializable] + public class ResultTransformer : IResultTransformer + { + private readonly Delegate _itemTransformation; + private readonly Delegate _listTransformation; - public ResultTransformer(Delegate itemTransformation, Delegate listTransformation) - { - _itemTransformation = itemTransformation; - _listTransformation = listTransformation; - } + public ResultTransformer(Delegate itemTransformation, Delegate listTransformation) + { + _itemTransformation = itemTransformation; + _listTransformation = listTransformation; + } - public object TransformTuple(object[] tuple, string[] aliases) - { - return _itemTransformation == null ? tuple : _itemTransformation.DynamicInvoke(new object[] { tuple } ); - } + #region IResultTransformer Members - public IList TransformList(IList collection) - { - if (_listTransformation == null) - { - return collection; - } + public object TransformTuple(object[] tuple, string[] aliases) + { + return _itemTransformation == null ? tuple : _itemTransformation.DynamicInvoke(new object[] {tuple}); + } - object transformResult = collection; + public IList TransformList(IList collection) + { + if (_listTransformation == null) + { + return collection; + } - //if (collection.Count > 0) - { - if (collection.Count > 0 && collection[0] is object[]) - { - if ( ((object[])collection[0]).Length != 1) - { - // We only expect single items - throw new NotSupportedException(); - } + object transformResult = collection; - transformResult = _listTransformation.DynamicInvoke(collection.Cast<object[]>().Select(o => o[0])); - } - else - { - transformResult = _listTransformation.DynamicInvoke(collection); - } - } + if (collection.Count > 0 && collection[0] is object[]) + { + if (((object[]) collection[0]).Length != 1) + { + // We only expect single items + throw new NotSupportedException(); + } - if (transformResult is IList) - { - return (IList) transformResult; - } + transformResult = _listTransformation.DynamicInvoke(collection.Cast<object[]>().Select(o => o[0])); + } + else + { + transformResult = _listTransformation.DynamicInvoke(collection); + } - var list = new ArrayList {transformResult}; - return list; - } + if (transformResult is IList) + { + return (IList) transformResult; + } - public bool Equals(ResultTransformer other) - { - if (ReferenceEquals(null, other)) - { - return false; - } - if (ReferenceEquals(this, other)) - { - return true; - } - return Equals(other._listTransformation, _listTransformation) && Equals(other._itemTransformation, _itemTransformation); - } + var list = new ArrayList {transformResult}; + return list; + } - public override bool Equals(object obj) - { - return Equals(obj as ResultTransformer); - } + #endregion - public override int GetHashCode() - { - unchecked - { - var lt = (_listTransformation != null ? _listTransformation.GetHashCode() : 0); - var it = (_itemTransformation != null ? _itemTransformation.GetHashCode() : 0); - return (lt * 397) ^ (it * 17); - } - } - } + public bool Equals(ResultTransformer other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return Equals(other._listTransformation, _listTransformation) && Equals(other._itemTransformation, _itemTransformation); + } + + public override bool Equals(object obj) + { + return Equals(obj as ResultTransformer); + } + + public override int GetHashCode() + { + unchecked + { + int lt = (_listTransformation != null ? _listTransformation.GetHashCode() : 0); + int it = (_itemTransformation != null ? _itemTransformation.GetHashCode() : 0); + return (lt*397) ^ (it*17); + } + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |