private void LoadMethodsFromAssembly(Assembly assembly) { foreach (var unit in units) { Type compiledRule = assembly.GetType(unit.ClassFullName); // Assign static helper fields CompiledRuleContext context = new CompiledRuleContext(unit.Rule); foreach (var helper in engine.HelperProvider.Helpers) { // Skip initialization of helpers that are not used in debug mode if debug mode is disabled if (helper.DebugModeOnly && !unit.IsDebugModeEnabled) { continue; } var field = compiledRule.GetField(helper.Name, BindingFlags.Static | BindingFlags.NonPublic); field.SetValue(null, helper.CreateInstance(context)); } if (unit.Rule.Where != null) { MethodInfo method = GetMethod(compiledRule, "Where"); unit.Rule.Where.Method = (Func <object, bool>)Delegate.CreateDelegate(typeof(Func <object, bool>), method); } if (unit.Rule.Select != null) { MethodInfo method = GetMethod(compiledRule, "Select"); unit.Rule.Select.Method = (Func <object, bool>)Delegate.CreateDelegate(typeof(Func <object, bool>), method); } if (unit.Rule.Update != null) { MethodInfo method = GetMethod(compiledRule, "Update"); unit.Rule.Update.Method = (Func <object, object, bool>)Delegate.CreateDelegate(typeof(Func <object, object, bool>), method); } if (unit.Rule.Inserts != null) { for (int i = 0; i < unit.Rule.Inserts.Length; i++) { MethodInfo method = GetMethod(compiledRule, "Insert_" + i); unit.Rule.Inserts[i].Method = (Func <object, object, bool>)Delegate.CreateDelegate(typeof(Func <object, object, bool>), method); } } } }
public EngineHelper(CompiledRuleContext context) { this.context = context; }
public FunctionsHelper(CompiledRuleContext context) { this.context = context; }
public object CreateInstance(CompiledRuleContext ruleContext) { return creator.Invoke(ruleContext); }
public FormsHelper(CompiledRuleContext context) { this.context = context; }
public DebugHelper(CompiledRuleContext context) { this.context = context; }
public object CreateInstance(CompiledRuleContext ruleContext) { return(creator.Invoke(ruleContext)); }