示例#1
0
        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);
                    }
                }
            }
        }
示例#2
0
 public EngineHelper(CompiledRuleContext context)
 {
     this.context = context;
 }
示例#3
0
 public FunctionsHelper(CompiledRuleContext context)
 {
     this.context = context;
 }
示例#4
0
 public object CreateInstance(CompiledRuleContext ruleContext)
 {
     return creator.Invoke(ruleContext);
 }
示例#5
0
 public FormsHelper(CompiledRuleContext context)
 {
     this.context = context;
 }
示例#6
0
 public DebugHelper(CompiledRuleContext context)
 {
     this.context = context;
 }
示例#7
0
 public object CreateInstance(CompiledRuleContext ruleContext)
 {
     return(creator.Invoke(ruleContext));
 }
示例#8
0
 public FunctionsHelper(CompiledRuleContext context)
 {
     this.context = context;
 }
示例#9
0
 public DebugHelper(CompiledRuleContext context)
 {
     this.context = context;
 }
示例#10
0
 public EngineHelper(CompiledRuleContext context)
 {
     this.context = context;
 }
示例#11
0
 public FormsHelper(CompiledRuleContext context)
 {
     this.context = context;
 }