Пример #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;
 }