コード例 #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
ファイル: YoloQL.cs プロジェクト: kouweizhong/noql
        public static INewCEPExpression <object> Input(this INewCEPExpression <object> expr, Func <object, object> action, INewCEPExpression exprToAttachTo)
        {
            //Do block logic here
            BaseInputAdapter adapter = new BaseInputAdapter();
            var perfExpress          = Yolo.Express().Perform(x => adapter.Send(action(x)));

            adapter.Attach(exprToAttachTo as INewComponent);
            adapter.Send(action(new object()));
            return(perfExpress);
        }
コード例 #3
0
 public void SetFunction(Action <DataType> func, INewComponent comp)
 {
     RecvFunction = func;
     if (mainExprFunc == null)
     {
         mainExprFunc = Yolo.Express <DataType>().Name("OutputAdapterFunc").Perform(x => func(x));
     }
     else
     {
         mainExprFunc.Perform(x => func(x));
     }
     comp.Attach(mainExprFunc);
 }
コード例 #4
0
 INewCEPExpression <OutputType> CompileAndReturn <OutputType>(INewCEPExpression <OutputType> expr)
 {
     //if (InputBlock.DebugName == "ExprStart") InputBlock = expr.InputBlock;
     //if (OutputBlock.DebugName == "ExprStart") OutputBlock = expr.InputBlock;
     //if (expr.InputBlock.DebugName == "ExprStart") expr.InputBlock = InputBlock;
     //if (expr.OutputBlock.DebugName == "ExprStart") expr.OutputBlock = InputBlock;
     //if (swap != null) this.Attach(swap);
     //else InputBlock = expr.OutputBlock;
     //swap = (INewCEPExpression<object>)expr;
     this.Attach(expr);
     //if ()
     return(this.NewExpr <OutputType>());
     //return this;
 }
コード例 #5
0
ファイル: RESTInterface.cs プロジェクト: kouweizhong/noql
        public string Post(PostExpr s)
        {
            Response.AddHeader("Access-Control-Allow-Origin", "*");
            string            exprString = Request.GetParam("expr");
            string            errors;
            INewCEPExpression expr = YoloMaker.MakeExpr(exprString, out errors);

            if (expr == null)
            {
                Response.StatusCode = 400;
                return(errors);
            }

            return("success");
        }
コード例 #6
0
ファイル: YoloCompile.cs プロジェクト: kouweizhong/noql
            public static INewCEPExpression MakeExpr(YoloItem item, string expr, string usings, string references, out string compileErrors)
            {
                string emptystr = " ";

                if (usings == null)
                {
                    usings = emptystr;
                }
                if (references == null)
                {
                    references = emptystr;
                }
                string code = Resources.superTemplateExpr.Replace("@@RETURN@@", expr);

                code = code.Replace("@@USINGS@@", usings);
                code = code.Replace("@@REFS@@", references);
                //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);

                //compiler.CompileAssemblyFromSource(compilerparams, 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;
                INewCEPExpression expr2 = Yolo.Express();

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

                if (item.ItemType == YoloItemType.Component)
                {
                    Yolo.Manager.Register(item.Name, 0);
                    ((INewComponent)expr2).Attach(Yolo.Manager.Get(item.Name));
                }
                if (item.ItemType == YoloItemType.Extension)
                {
                    Yolo.Expressions.AddExpression(item.Name);
                }
                compileErrors = "";
                return(expr2);

                return(null);
            }
コード例 #7
0
 public void AddExpression(INewCEPExpression <object> expr)
 {
     Expressions.Add(expr);
 }
コード例 #8
0
 public INewCEPExpression <InputType> Where(Func <InputType, bool> whereFunc, out INewCEPExpression <InputType> elseBranch)
 {
     throw new NotImplementedException();
 }
コード例 #9
0
 public INewCEPExpression <InputType> NotIn(INewCEPExpression <InputType> expr)
 {
     throw new NotImplementedException();
 }
コード例 #10
0
ファイル: YoloQL.cs プロジェクト: kouweizhong/noql
 public static INewCEPExpression <object> Input(Func <object, object> GenerateInputFunc, INewCEPExpression exprToSendInputTo)
 {
     return(Yolo.Express().Input(GenerateInputFunc, exprToSendInputTo));
 }