示例#1
0
 public INewCEPExpression <InputType> Branch <InputType>(out INewCEPExpression <InputType> expr)
 {
     expr = Yolo.Express <InputType>();
     this.Attach(expr);
     return(new NewAbstractCEPExpression <InputType>(this.InputBlock, this.OutputBlock));
     //return new NewAbstractCEPExpression<InputType>();
 }
示例#2
0
        public static void Main(string[] args)
        {
            var p = new Processor(2, 1);


            //Yolo.Manager.Register("example1", 0);
            var expr1 = Yolo.Express <int>().Where(x => x > 5).Perform(x => System.Console.WriteLine(x));

            //.Manager.Get("example1").Attach(expr1);
            expr1.Send(10);

            expr1.Send(4);
        }
示例#3
0
            public static INewCEPExpression MakeExpr(string expr, out string compileErrors)
            {
                Yolo.Express();
                //string code = Resource1.template;
                string code = Resources.templateExpr.Replace(REPLACE_TOKEN, expr);
                //string code = File.ReadAllText(TEMPLATE_PATH).Replace(REPLACE_TOKEN, lambda);

                var provider = new CSharpCodeProvider(
                    new Dictionary <String, String> {
                    { "CompilerVersion", "v4.0" }
                });
                ICodeCompiler compiler = provider.CreateCompiler();

                var compilerparams = new CompilerParameters();

                compilerparams.GenerateExecutable = false;
                compilerparams.GenerateInMemory   = true;

                IEnumerable <string> referencedAssemblies = typeof(YoloWrapper).Assembly.GetReferencedAssemblies().Select(a => a.Name);

                foreach (string referencedAssembly in referencedAssemblies)
                {
                    string name = referencedAssembly + ".dll";
                    if (name != "WindowsBase.dll")
                    {
                        compilerparams.ReferencedAssemblies.Add(name);
                    }
                }

                //compilerparams.ReferencedAssemblies.Add(typeof(YoloWrapper).Assembly.GetName().Name + ".exe");

                foreach (string f in Directory.GetFiles(Environment.CurrentDirectory, "*.dll"))
                {
                    compilerparams.ReferencedAssemblies.Add(f);
                }

                CompilerResults results = RuntimeCodeCompiler.CompileCode(code);

                if (results.Errors.HasErrors)
                {
                    var errors = new StringBuilder("Compiler Errors :\r\n");
                    foreach (CompilerError error in results.Errors)
                    {
                        errors.AppendFormat("Line {0},{1}\t: {2}\n",
                                            error.Line, error.Column, error.ErrorText);
                    }
                    Console.Write("-");
                    compileErrors = errors.ToString();
                    throw new Exception(errors.ToString());
                }
                compileErrors = "";

                Assembly assm = results.CompiledAssembly;

                foreach (Type t in assm.DefinedTypes)
                {
                    object wrapper = Activator.CreateInstance(t);
                    return((INewCEPExpression)t.InvokeMember("Generate", BindingFlags.InvokeMethod, null, wrapper, null));
                }
                compileErrors = "";
                return(null);
            }