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>(); }
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); }
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); }
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; }
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"); }
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); }
public void AddExpression(INewCEPExpression <object> expr) { Expressions.Add(expr); }
public INewCEPExpression <InputType> Where(Func <InputType, bool> whereFunc, out INewCEPExpression <InputType> elseBranch) { throw new NotImplementedException(); }
public INewCEPExpression <InputType> NotIn(INewCEPExpression <InputType> expr) { throw new NotImplementedException(); }
public static INewCEPExpression <object> Input(Func <object, object> GenerateInputFunc, INewCEPExpression exprToSendInputTo) { return(Yolo.Express().Input(GenerateInputFunc, exprToSendInputTo)); }