public static FunctionActionContainer Serialize(FunctionAction messageAction) { return new FunctionActionContainer( messageAction.Type.AssemblyQualifiedName, messageAction.Method.Name, messageAction.Method.GetParameters().Select(x => x.ParameterType).ToArray(), messageAction.Arguments); }
public Function(string name, string tooltip, Image img, FunctionAction action, FunctionAction edit, Parameter[] param) { this.name = name; this.tooltip = tooltip; this.img = img; this.action = action; this.edit = edit; this.param = param; }
public async Task ExecuteAsync_executes_Action() { const double updatedBalance = 1.23; var sale = new Sale(saleID: 5) { Balance = 0 }; var sut = new FunctionAction <Sale>((sale1, _) => Task.FromResult(sale1.Balance = updatedBalance)); await sut.ExecuteAsync(sale, request : null, cancellationToken : default(CancellationToken)); Assert.Equal(updatedBalance, sale.Balance); }
protected void parse(Rete engine, CLIPSParser parser, IList factlist) { Object itm = null; try { while ((itm = parser.basicExpr()) != null) { // System.Console.WriteLine("obj is " + itm.getClass().Name); if (itm is Defrule) { Defrule rule = (Defrule)itm; engine.RuleCompiler.addRule(rule); } else if (itm is Deftemplate) { Deftemplate dt = (Deftemplate)itm; Console.WriteLine("template=" + dt.Name); engine.declareTemplate(dt); } else if (itm is FunctionAction) { FunctionAction fa = (FunctionAction)itm; } else if (itm is IFunction) { IReturnVector rv = ((IFunction)itm).executeFunction(engine, null); IEnumerator itr = rv.Iterator; while (itr.MoveNext()) { IReturnValue rval = (IReturnValue)itr.Current; Console.WriteLine(rval.StringValue); } } } } catch { // Console.WriteLine(e.Message); parser.ReInit(Console.OpenStandardInput()); } }
public void ExecuteAsync_can_be_cancelled() { using (var cancellationSource = new CancellationTokenSource()) { var sale = new Sale(saleID: 3); var wasCancelled = false; var mutex = new Mutex(initiallyOwned: false); var sut = new FunctionAction <Sale>((_, cancelToken) => { mutex.WaitOne(); do { Task.Delay(millisecondsDelay: 123).Wait(); } while (!cancelToken.IsCancellationRequested); mutex.ReleaseMutex(); wasCancelled = true; return(Task.FromCanceled(cancelToken)); }); Task.Factory.StartNew(async() => { await sut.ExecuteAsync(sale, cancellationSource.Token, request: null); }, TaskCreationOptions.LongRunning); try { Task.Delay(555).Wait(); cancellationSource.Cancel(); } catch { cancellationSource.Cancel(); } mutex.WaitOne(); Assert.True(wasCancelled); } }
private bool TryParseFunctional(string path, out FunctionAction function) { function = null; return(_functions != null && _functions.TryGetValue(path, out function)); }
public FunctionButton(string display, FunctionAction functionAction) : base(display) { this.functionAction = functionAction; }