public KLoadedXRule(IXRule xRule, string source)
 {
     XRule = xRule;
     Source = source;
     methods = new Dictionary<XRuleAttribute, MethodInfo>();
     foreach (var method in DI.reflection.getMethods(XRule.GetType()))
     {
         var attribute = (XRuleAttribute)DI.reflection.getAttribute(method, typeof(XRuleAttribute));
         if (attribute != null && false == methods.ContainsKey(attribute))
             methods.Add(attribute, method);
     }
 }
 public KLoadedXRule(IXRule xRule, string source)
 {
     XRule   = xRule;
     Source  = source;
     methods = new Dictionary <XRuleAttribute, MethodInfo>();
     foreach (var method in PublicDI.reflection.getMethods(XRule.GetType()))
     {
         var attribute = (XRuleAttribute)PublicDI.reflection.getAttribute(method, typeof(XRuleAttribute));
         if (attribute != null && false == methods.ContainsKey(attribute))
         {
             methods.Add(attribute, method);
         }
     }
 }
Beispiel #3
0
 private static void executeMethod(IXRule resolvedXRule, MethodInfo resolvedMethod, object[] methodParameters)
 {
     /* var appDomainFactory = new O2AppDomainFactory("test", XRules_Config.PathTo_XRulesCompiledDlls);
      *
      * O2Cmd.log.info("executing via AppDomain");
      */
     Console.WriteLine("\nExecuting XRule's method: {0}  [{1}]\n", resolvedMethod.Name, resolvedMethod);
     DI.reflection.invokeASync(resolvedXRule, resolvedMethod, methodParameters,
                               results =>
     {
         O2Cmd.log.write("\nExecution Results: {0}\n", results ?? "[null]");
         executionComplete = true;
     });
     while (executionComplete == false)
     {
         Processes.Sleep(100, false);
     }
     Console.WriteLine("\nXRule's method execution complete");
 }
Beispiel #4
0
        private static void onCompilationComplete(List <IXRule> xRules, string ruleToExecute, string methodToExecute, string[] methodParameters)
        {
            var loadedXRules = XRules_Execution.getLoadedXRules(xRules);

            Console.WriteLine("\nCompilation Done, now finding rule '{0}' and method '{1}'", ruleToExecute,
                              methodToExecute);
            MethodInfo resolvedMethod = null;
            IXRule     resolvedXRule  = null;

            foreach (var loadedXRule in loadedXRules)
            {
                if (loadedXRule.XRule.Name == ruleToExecute)
                {
                    foreach (var method in loadedXRule.methods)
                    {
                        if (method.Key.Name == methodToExecute)
                        {
                            resolvedXRule  = loadedXRule.XRule;
                            resolvedMethod = method.Value;
                            break;
                        }
                    }
                }
                if (resolvedMethod != null)
                {
                    break;
                }
            }
            if (resolvedMethod != null)
            {
                executeMethod(resolvedXRule, resolvedMethod, methodParameters);
            }
            else
            {
                Console.WriteLine("\nERROR: Could NOT findmethod to execute");
            }
            compilationComplete = true;
        }
Beispiel #5
0
 private static void executeMethod(IXRule resolvedXRule, MethodInfo resolvedMethod, object[] methodParameters)
 {
    /* var appDomainFactory = new O2AppDomainFactory("test", XRules_Config.PathTo_XRulesCompiledDlls);
     
     O2Cmd.log.info("executing via AppDomain");            
     */
     Console.WriteLine("\nExecuting XRule's method: {0}  [{1}]\n", resolvedMethod.Name, resolvedMethod);
     DI.reflection.invokeASync(resolvedXRule, resolvedMethod, methodParameters,
                            results =>
                                {
                                    O2Cmd.log.write("\nExecution Results: {0}\n" , results ?? "[null]" );
                                    executionComplete = true;
                                });            
     while (executionComplete == false)
     {
         Processes.Sleep(100,false);
     }
     Console.WriteLine("\nXRule's method execution complete");
 }