/// <summary> /// Go through all methods of a type and try to add them as formula functions /// </summary> private void AddFormulaMethods(Type targetType, IDelegateCreator creator) { ValidateEngineStateForChangingFunctions(); BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | creator.Flags; foreach (MethodInfo mi in targetType.GetMethods(flags)) { var attr = (FormulaFunctionAttribute)Attribute.GetCustomAttribute(mi, typeof(FormulaFunctionAttribute)); if (attr != null) { FormulaFunctionCall d = creator.CreateDelegate(mi.Name); if (d == null) { throw new ArgumentException(String.Format("The method {0} is marked as a formula function but does not have the correct signature", mi.Name)); } var info = new FunctionInfo(d, attr); AddFunctionInternal(info); } } }
public static void Register(IDelegateCreator creator) { dict.Clear(); creator.Register(); }
public static void Init(IDelegateCreator creator) { Register(creator); }