protected override object Call(CallAction action, params object[] args) { string name = action.Name; if (String.CompareOrdinal(name, "SelectAll") == 0) { IEnumerable<XElement> selectedElements = null; if (args.Length == 0) { selectedElements = _element.Descendants(); } else { selectedElements = _element.Descendants(args[0].ToString()); } return new XmlNodeList(selectedElements); } else if (String.CompareOrdinal(name, "SelectChildren") == 0) { IEnumerable<XElement> selectedElements = null; if (args.Length == 0) { selectedElements = _element.Elements(); } else { selectedElements = _element.Elements(args[0].ToString()); } return new XmlNodeList(selectedElements); } return base.Call(action, args); }
public GeneratedVariable Call(Func<GeneratedMethod> method, Type returnType) { var action = new CallAction(bundle, method, actions, this, () => new List<GeneratedField>()); actions.Add(action); return new GeneratedVariable(returnType, action.LocalIndex, actions, this); }
public GeneratedVariable Call(Func<MethodInfo> method, Func<List<IGeneratedParameter>> parameters) { var action = new CallAction(bundle, method, actions, this, parameters); actions.Add(action); return new GeneratedVariable(method().ReturnType, action.LocalIndex, actions, this); }
public void HaveParameter_Fail_Null() { CallAction action = CallAction.Construct(parameters: new object[] { 1, null }); ((Action)(() => action.Should().HaveParameterN(0, null))).Should().Throw <XunitException>(); ((Action)(() => action.Should().HaveNullParameterN(1))).Should().Throw <XunitException>(); }
public void HaveParameter_Fail_Value() { CallAction action = CallAction.Construct(parameters: new object[] { 1, new Null <string>() }); ((Action)(() => action.Should().HaveParameterN(0, "a"))).Should().Throw <XunitException>(); ((Action)(() => action.Should().HaveParameterN(1, 10))).Should().Throw <XunitException>(); }
public void HaveParameter_OK_Value() { CallAction action = CallAction.Construct(parameters: new object[] { 1, 2 }); ((Action)(() => action.Should().HaveParameterN(0, 1))).Should().NotThrow <XunitException>(); ((Action)(() => action.Should().HaveParameterN(1, 2))).Should().NotThrow <XunitException>(); }
public void HaveParameter_OK_Null() { CallAction action = CallAction.Construct(parameters: new object[] { 1, new Null <string>() }); ((Action)(() => action.Should().HaveParameterN(1, null))).Should().NotThrow <XunitException>(); ((Action)(() => action.Should().HaveNullParameterN(1))).Should().NotThrow <XunitException>(); }
public async Task <IActionResult> PutCallAction(int id, CallAction callAction) { if (id != callAction.Id) { return(BadRequest()); } _context.Entry(callAction).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CallActionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <CallAction> > PostCallAction(CallAction callAction) { _context.CallAction.Add(callAction); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCallAction", new { id = callAction.Id }, callAction)); }
public GeneratedVariable Call(Func <GeneratedMethod> method, Type returnType) { var action = new CallAction(bundle, method, actions, this, () => new List <GeneratedField>()); actions.Add(action); return(new GeneratedVariable(returnType, action.LocalIndex, actions, this)); }
public GeneratedVariable Call(Func <GeneratedMethod> method, Func <List <GeneratedField> > parameters) { var action = new CallAction(bundle, method, actions, this, parameters); actions.Add(action); return(new GeneratedVariable(method, action.LocalIndex, actions, this)); }
public GeneratedVariable Call(Func <MethodInfo> method, Func <List <IGeneratedParameter> > parameters) { var action = new CallAction(bundle, method, actions, this, parameters); actions.Add(action); return(new GeneratedVariable(method().ReturnType, action.LocalIndex, actions, this)); }
private static void defmeth(Tokenizer tokenizer) { // ptype0 ptype1 ... cParms objType "dnName fName" => new method primitive named "fName" // where dnName is the actual name of the .NET function and fName is the name we use in // Forth. This is necessary due to .NET's overloading. Each overload requires a different // name in Forth. CallAction.CreateMethod(tokenizer); }
public void ParseStaticExpression() { var action = CallAction.Let <TestActionObject>("v1", null, _ => TestActionObject.Method1()); action.Should().SaveTo("v1"); action.Should().CallStatic(typeof(TestActionObject), "Method1"); action.Should().HaveNoParameters(); }
public void ParseInstanceExpression() { var action = CallAction.Let <TestActionObject>("v1", "v2", v => v.Method2()); action.Should().SaveTo("v1") .And.CallInstance("v2", "Method2") .And.HaveNoParameters(); }
// Lists read easier with the label as the first param public TaskDelegate(string label, CallAction callAction, bool useTask = false, bool showTask = false, string description = null) { Label = label; Action = callAction; UseTask = useTask; ShowTask = showTask; Description = description; }
internal override ExitType Eval(Tokenizer tokenizer = null, WordListBuilder wlb = null) { var passedParms = GetPassedParms(); var result = _constructor.Invoke(passedParms); CallAction.HandleResult(TRet, result); return(ExitType.Okay); }
public TaskDelegate(CallAction callAction, bool useTask = false, bool showTask = false, string description = null) { Label = callAction.Method.Name; Action = callAction; UseTask = useTask; ShowTask = showTask; Description = description; }
public void CalculateParameterFromConstants() { var action = CallAction.Let <TestActionObject>("v1", null, _ => TestActionObject.Duplicate(10 + 5)); action.Should().SaveTo("v1") .And.CallStatic <TestActionObject>("Duplicate") .And.HaveParametersCount(1) .And.HaveParameterN(0, 15); }
public void VariableParameter() { var action = CallAction.Let <TestActionObject>("v1", null, _ => TestActionObject.Duplicate((new Variable <int>("a")).Value)); action.Should().SaveTo("v1") .And.CallStatic <TestActionObject>("Duplicate") .And.HaveParametersCount(1) .And.HaveVariableParameterN <int>(0, "a"); }
protected override object Call(CallAction action, params object[] args) { string operation = action.Name; if (_operationGroup != null) { operation = _operationGroup + "." + operation; } return PerformOperation(operation, args); }
public override MetaObject Call(CallAction action, MetaObject[] args) { if (ImplementsActions(StandardActionKinds.Call)) { return(CallMethodNAry(action, args, "Call")); } return(base.Call(action, args)); }
internal override ExitType Eval(Tokenizer tokenizer = null, WordListBuilder wlb = null) { var obj = _isStatic ? null : Session.GetManagedObject(Session.Stack.Pop()); var passedParms = GetPassedParms(); var result = _method.Invoke(obj, passedParms); CallAction.HandleResult(TRet, result); return(ExitType.Okay); }
/// <summary> /// /// </summary> /// <param name="call"></param> /// <param name="callAction"></param> public override void OnEndLinkLine(Call call, CallAction callAction) { try { CallAction = callAction; } catch (Exception exception) { Logger.Instance.LogMessage(Logger.LogAppender.DuoLogger3, string.Empty, exception, Logger.LogLevel.Error); throw; } }
public void NullParameter() { var action = CallAction.Let <TestActionObject>("v1", null, _ => TestActionObject.Stringize(null)); action.Should().SaveTo("v1") .And.CallStatic <TestActionObject>("Stringize") .And.HaveParametersCount(1) .And.HaveNullParameterN(0); }
public void CalculateParameterFromExternals() { const int a = 10; const int b = 5; var action = CallAction.Let <TestActionObject>("v1", null, _ => TestActionObject.Duplicate(a + b)); action.Should().SaveTo("v1") .And.CallStatic <TestActionObject>("Duplicate") .And.HaveParametersCount(1) .And.HaveParameterN(0, 15); }
public void ParseParameters() { var action = CallAction.Let <TestActionObject>("v1", null, _ => TestActionObject.Formula(10, 20, 5)); action.Should().SaveTo("v1") .And.CallStatic <TestActionObject>("Formula") .And.HaveParametersCount(3) .And.HaveParameterN(0, 10) .And.HaveParameterN(1, 20) .And.HaveParameterN(2, 5); }
public CallActionResult InsertCallLoggerAction(string patientID, CallAction action) { try { return(Util.PostDataToService <CallActionResult>(String.Concat(Config.BaseAddress, "api/patients/callaction/", GlobalVariables.ActiveClinic.ClinicId, "/", patientID), action)); } catch (Exception ex) { throw Util.HandleAPIException(ex, "InsertCallLoggerAction"); } }
protected override object Call(CallAction action, params object[] args) { if (String.Compare(action.Name, "Item", StringComparison.Ordinal) == 0) { if (args.Length == 1) { XElement element = _elements[System.Convert.ToInt32(args[0])]; return new XmlNode(element); } } return base.Call(action, args); }
public void StaticCall() { TestActionObject.Method1Called = false; Variables variables = new Variables(); var action = CallAction.Let("v1", typeof(TestActionObject), "Method1", Array.Empty <Type>()); action.Execute(variables); TestActionObject.Method1Called.Should().BeTrue(); variables["v1"].Should().BeOfType <TestActionObject>(); }
public void CallWithParameter() { TestActionObject.Method1Called = false; Variables variables = new Variables(); var action = CallAction.Let("v2", typeof(TestActionObject), "Duplicate", 7 + 3); action.Execute(variables); variables["v2"].Should().BeOfType <int>(); variables["v2"].Should().Be(20); }
private static Queue <CallAction> CreateXYZ() { Queue <CallAction> queue = new Queue <CallAction>(); var action = CallAction.Construct(saveTo: "x"); queue.Enqueue(action); action = CallAction.Construct(saveTo: "y"); queue.Enqueue(action); action = CallAction.Construct(saveTo: "z"); queue.Enqueue(action); return(queue); }
public void InstanceCallWithNull() { TestActionObject.Method1Called = false; Variables variables = new Variables(); var action = CallAction.Let("v2", typeof(TestActionObject), "Stringize", new Null <object>()); action.Execute(variables); variables["v2"].Should().BeOfType <string>(); variables["v2"].Should().Be("null"); }
public void MultipleParameter() { TestActionObject.Method1Called = false; Variables variables = new Variables(); var action = CallAction.Let("v2", typeof(TestActionObject), "Formula", 2, 4, 5); action.Execute(variables); variables["v2"].Should().BeOfType <int>(); variables["v2"].Should().Be(1); }
public ILocalIndexer Call(Func <MethodInfo> method, params ILocalIndexer[] variables) { var action = new CallAction(bundle, method, actions, this); foreach (ILocalIndexer variable in variables) { action.WithArgument(variable); } actions.Add(action); return(new GeneratedVariable(method, action.LocalIndex, actions, this)); }
public GeneratedVariable Call(Func<DelegateMethod> method, Func<List<GeneratedField>> parameters) { var action = new CallAction(bundle, method, actions, this, parameters); actions.Add(action); return new GeneratedVariable(method, action.LocalIndex, actions, this); }
/// <summary> /// When overridden in a derived class provides the non-Meta implementation of calling a member /// in the expando. /// /// When not overridden the call site requesting the action determines the behavior. /// </summary> protected virtual object Call(CallAction action, params object[] args) { throw new NotSupportedException(); }
public override MetaObject Call(CallAction action, MetaObject[] args) { if (ImplementsActions(StandardActionKinds.Call)) { return CallMethodNAry(action, args, "Call"); } return base.Call(action, args); }
/// <summary> /// Creates ActionExpression representing a Call action. /// </summary> /// <param name="action">The call action to perform.</param> /// <param name="result">Type of the result desired (The ActionExpression is strongly typed)</param> /// <param name="arguments">Array of arguments for the action expression</param> /// <returns>New instance of the ActionExpression</returns> public static ActionExpression Call(CallAction action, Type result, params Expression[] arguments) { return ActionExpression(action, arguments, result); }
public ILocalIndexer Call(Func<MethodInfo> method, params ILocalIndexer[] variables) { var action = new CallAction(bundle, method, actions, this); foreach(ILocalIndexer variable in variables) { action.WithArgument(variable); } actions.Add(action); return new GeneratedVariable(method, action.LocalIndex, actions, this); }