protected CallbackBase(long id, ICallbackExecutor <TMarshal> executor, BindingDelegate <TMarshal> parameterBinder, Type resultType) { this.id = id; this.executor = executor; this.parameterBinder = parameterBinder; this.resultType = resultType; }
public object CreateCallback(long id, Type delegateType, BindingDelegate <TMarshal> parameterBinder) { if (delegateType == null) { return(Create(id, parameterBinder)); } else { return(Create(id, delegateType, parameterBinder)); } }
public async Task CallbackExecuted() { var executor = Mock.Of <ICallbackExecutor <object> >(); var executorMock = Mock.Get(executor); BindingDelegate <object> parameterBinder = context => { }; executorMock .Setup(_ => _.Execute(It.Is <CallbackExecutionParameters <object> >(o => o.Parameters.Length == 1 && o.Binder == parameterBinder && o.ResultTargetType == typeof(string)))).Returns(Task.FromResult(new object())); executorMock.SetupGet(_ => _.CanExecute).Returns(true); var callback = new TestCallback(1, executor, parameterBinder, typeof(string)); var result = await callback.ExecuteAsync("str"); Assert.NotNull(result); }
/// <summary> /// この式を評価する。 /// </summary> /// <returns>評価結果</returns> /// <param name="binding">変数のバインディング</param> public Value Evaluate(BindingDelegate binding) { var func = binding(_func) as Delegate; var p = func.Method.GetParameters(); if (_args.Count < p.Length) { throw new ArgumentException("Wrong number of arguments: " + _func); } var args = new object[p.Length]; for (var i = 0; i < _args.Count; i++) { args[i] = _args[i].Evaluate(binding).As(p[i].ParameterType); } return(new Value(func.DynamicInvoke(args))); }
/// <summary> /// 数学ライブラリを呼び出すバインディングを生成する。 /// </summary> /// <returns>結果</returns> /// <param name="defaultBinding">デフォルトのバインディング</param> public static BindingDelegate Binding(BindingDelegate defaultBinding) { return((name) => { if (Constants.ContainsKey(name)) { return Constants[name]; } if (Functions.ContainsKey(name)) { return Functions[name]; } if (defaultBinding != null) { return defaultBinding(name); } return 0.0; }); }
public void TypedCallbackCallsFactory() { BindingDelegate <object> bindingDelegate = context => { }; var callbackFactoryMock = new Mock <ICallbackFactory <object> >(); callbackFactoryMock.Setup(_ => _.CreateCallback(1, typeof(Action), bindingDelegate)).Returns("str"); var binder = new CallbackBinder <object>(context => { context.ObjectValue = new CallbackDescriptor { FunctionId = 1 }; }, callbackFactoryMock.Object); var ctx = new BindingContext <object>(ObjectBindingDirection.In, bindingDelegate); ctx.TargetType = typeof(Action); binder.Bind(ctx); Assert.Equal("str", ctx.ObjectValue); }
public void FailedCreationSetsNull() { BindingDelegate <object> bindingDelegate = context => { }; var callbackFactoryMock = new Mock <ICallbackFactory <object> >(); callbackFactoryMock.Setup(_ => _.CreateCallback(1, typeof(Action), bindingDelegate)) .Throws(new InvalidOperationException()); var binder = new CallbackBinder <object>(context => { context.ObjectValue = new CallbackDescriptor { FunctionId = 1 }; }, callbackFactoryMock.Object); var ctx = new BindingContext <object>(ObjectBindingDirection.In, bindingDelegate); ctx.TargetType = typeof(Action); binder.Bind(ctx); Assert.Null(ctx.ObjectValue); }
public Delegate Generate(Type delegateType, long id, ICallbackExecutor <TMarshal> callbackExecutor, BindingDelegate <TMarshal> parameterBinder) { ValidateDelegateType(delegateType); if (!typeCache.TryGetValue(delegateType, out var delegateContainerType)) { delegateContainerType = GenerateDelegateContainerType(delegateType); typeCache.Add(delegateType, delegateContainerType); } var created = Activator.CreateInstance(delegateContainerType, id, callbackExecutor, parameterBinder, delegateType); return(Delegate.CreateDelegate(delegateType, created, DelegateMethodName, false, true));; }
public PlatformBinder(BindingDelegate <TMarshal> next, IPlatformBinder <TMarshal> marshal) { this.marshal = marshal; }
public Callback(long id, ICallbackExecutor <TMarshal> executor, BindingDelegate <TMarshal> parameterBinder) : base(id, executor, parameterBinder, typeof(object)) { }
/// <summary> /// この式を評価する。 /// </summary> /// <returns>評価結果</returns> /// <param name="binding">変数のバインディング</param> public Value Evaluate(BindingDelegate binding) { return(_value); }
public TestCallback(long id, ICallbackExecutor <object> executor, BindingDelegate <object> parameterBinder, Type resultType) : base(id, executor, parameterBinder, resultType) { }
public MethodExecutor(IReadOnlyDictionary <long, ObjectDescriptor> objects, BindingDelegate <TMarshal> bindingDelegate) { this.objects = objects; this.bindingDelegate = bindingDelegate; }
public PropertyExecutor(IReadOnlyDictionary <long, ObjectDescriptor> objects, BindingDelegate <TMarshal> binder) { this.objects = objects; this.binder = binder; }
public OutgoingValueBinder(BindingDelegate <TMarshal> next, IBindingRepository bindingRepository) { this.next = next; this.bindingRepository = bindingRepository; }
private ICallback Create(long id, BindingDelegate <TMarshal> parameterBinder) { return(new Callback <TMarshal>(id, callbackExecutor, parameterBinder)); }
public Binder(BindingDelegate <object> next) { this.next = next; }
public DelegateContainerBase(long id, ICallbackExecutor <TMarshal> executor, BindingDelegate <TMarshal> parameterBinder, Type resultType, Type delegateType) : base(id, executor, parameterBinder, resultType) { bindValues = delegateType.GetMethod(nameof(Action.Invoke)).GetParameters() .Select(p => p.GetCustomAttribute <BindValueAttribute>()).ToArray(); }
public CommandBindingExpression(BindingCompilationService service, BindingDelegate command, string id) : base(service, new object[] { command, new IdBindingProperty(id), new CommandJavascriptBindingProperty(CreateJsPostbackInvocation(id)) }) { }
/// <summary> /// このノードを評価する。 /// </summary> /// <returns>評価結果</returns> /// <param name="binding">変数のバインディング</param> public Value Evaluate(BindingDelegate binding) { return(new Value(binding(_name))); }
/// <summary> /// この式を評価する。 /// </summary> /// <returns>評価結果</returns> /// <param name="binding">変数のバインディング</param> public Value Evaluate(BindingDelegate binding) { return(Value.EvaluateUnaryOperator(_expression.Evaluate(binding), _op)); }
public BinderWithCtrArgs(BindingDelegate <object> next, string arg) { this.next = next; this.arg = arg; }
public BindingContext(ObjectBindingDirection direction, BindingDelegate <TMarshal> binder) { Direction = direction; Binder = binder; }
/// <summary> /// 数式を評価する。 /// </summary> /// <returns>評価結果</returns> /// <param name="binding">変数のバインディング</param> Value Evaluate(BindingDelegate binding) { binding = Math.Binding(binding); return(_expression.Evaluate(binding)); }
private Delegate Create(long id, Type delegateType, BindingDelegate <TMarshal> parameterBinder) { return(generator.Generate(delegateType, id, callbackExecutor, parameterBinder)); }
/// <summary> /// 数式を評価する。 /// </summary> /// <returns>評価結果</returns> /// <param name="expression">数式</param> /// <param name="binding">変数のバインディング</param> static public T Evaluate <T>(string expression, BindingDelegate binding) { return((new Expression(expression)).Evaluate <T>(binding)); }
public CallbackBinder(BindingDelegate <TMarshal> next, ICallbackFactory <TMarshal> callbackFactory) { this.next = next; this.callbackFactory = callbackFactory; }
/// <summary> /// 数式を評価する。 /// </summary> /// <returns>評価結果</returns> /// <param name="binding">変数のバインディング</param> public T Evaluate <T>(BindingDelegate binding) { binding = Math.Binding(binding); return((T)_expression.Evaluate(binding).As(typeof(T))); }
public FakeCommandBinding(ParametrizedCode commandJavascript, BindingDelegate bindingDelegate) { this.commandJavascript = commandJavascript; this.bindingDelegate = bindingDelegate; }
/// <summary> /// この式を評価する。 /// </summary> /// <returns>評価結果</returns> /// <param name="binding">変数のバインディング</param> public Value Evaluate(BindingDelegate binding) { return(Value.EvaluateBinaryOperator(_left.Evaluate(binding), _right.Evaluate(binding), _op)); }