/// <summary> /// Creates a delegate from a MethodInfo using <see cref="System.Linq.Expressions.Expression.GetDelegateType"/> /// </summary> /// <param name="method"></param> /// <returns></returns> public static System.Delegate CreateDelegate(System.Reflection.MethodInfo method) { if (method == null) { throw new System.ArgumentNullException("method"); } return(method.CreateDelegate(System.Linq.Expressions.Expression.GetDelegateType(method.GetParameters().Select(p => p.ParameterType).Concat(LinqExtensions.Yield(method.ReturnType)).ToArray()))); }