Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created November 14, 2009 21:27
Show Gist options
  • Save jfromaniello/234794 to your computer and use it in GitHub Desktop.
Save jfromaniello/234794 to your computer and use it in GitHub Desktop.
//USAGE:
.SetResultTransformer(new DelegateTransformer<SomeNoSeQue>(m => new SomeNoSeQue((int)m[0],(string)m[1]){ Algo = m[3] });
[Serializable]
public class DelegateTransformer<TEntity> : IResultTransformer
{
private readonly Func<object[], TEntity> _transformFucntion;
public DelegateTransformer(Func<object[], TEntity> transformFucntion)
{
_transformFucntion = transformFucntion;
}
#region IResultTransformer Members
public IList TransformList(IList collection)
{
return collection;
}
public object TransformTuple(object[] tuple, string[] aliases)
{
return _transformFucntion(tuple);
}
#endregion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment