internal static Delegate Deserialize(UdfData udfData) { Type udfType = DeserializeType(udfData.TypeData); MethodInfo udfMethod = udfType.GetMethod( udfData.MethodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); var udfParameters = udfMethod.GetParameters().Select(p => p.ParameterType).ToList(); udfParameters.Add(udfMethod.ReturnType); Type funcType = Expression.GetFuncType(udfParameters.ToArray()); if (udfData.TargetData == null) { // The given UDF is a static function. return(Delegate.CreateDelegate(funcType, udfMethod)); } else { return(Delegate.CreateDelegate( funcType, DeserializeTargetData(udfData.TargetData), udfData.MethodName)); } }
public bool Equals(UdfData other) { return((other != null) && TypeData.Equals(other.TypeData) && (MethodName == other.MethodName) && TargetData.Equals(other.TargetData)); }
internal static UdfData Serialize(Delegate udf) { MethodInfo method = udf.Method; object target = udf.Target; var udfData = new UdfData() { TypeData = SerializeType(method.DeclaringType), MethodName = method.Name, TargetData = SerializeTarget(target) }; return(udfData); }