public static IProjectionDescription CreateStructFunction(Delegate selector) { Guard.NotNull(selector, nameof(selector)); var invocationList = selector.GetInvocationList(); if (invocationList.Length != 1) { throw new ArgumentException($"Delegate {selector.ToString()} must point to a single method."); } selector = invocationList[0]; if (selector.Method.ReturnType == typeof(void)) { throw new ArgumentException($"Delegate {selector.ToString()} must return a type other than System.Void."); } Type structSelectorType = selectorDictionary[selector.Method]; return((IProjectionDescription)CodeGenerationContext.CreateStructProxyInstance(structSelectorType, selector)); }
public static IProjection <TSource, TResult> CreateStructFunction <TSource, TResult>(Func <TSource, TResult> selector) { return((IProjection <TSource, TResult>)CodeGenerationContext.CreateStructFunction((Delegate)selector)); }