public async Task <int> InvokeAsync(InvocationContext context)
        {
            var bindingContext = context.BindingContext;

            var(boundValues, _) = ModelBinder.GetBoundValues(
                invokeArgumentBindingSources,
                bindingContext,
                _methodDescriptor.ParameterDescriptors,
                _enforceExplicitBinding);

            var invocationArguments = boundValues
                                      .Select(x => x.Value)
                                      .ToArray();

            object result;

            if (_handlerDelegate is null)
            {
                var invocationTarget = _invocationTarget ??
                                       _invocationTargetBinder?.CreateInstance(bindingContext);
                result = _handlerMethodInfo !.Invoke(invocationTarget, invocationArguments);
            }
            else
            {
                result = _handlerDelegate.DynamicInvoke(invocationArguments);
            }

            return(await CommandHandler.GetResultCodeAsync(result, context));
        }
Exemplo n.º 2
0
        public async Task <int> InvokeAsync(InvocationContext context)
        {
            var bindingContext = context.BindingContext;

            var parameterBinders = _parameterDescriptors
                                   .Select(p => bindingContext.GetModelBinder(p))
                                   .ToList();

            var invocationArguments =
                parameterBinders
                .Select(binder => binder.CreateInstance(bindingContext))
                .ToArray();

            var invocationTarget = _invocationTarget ??
                                   _invocationTargetBinder?.CreateInstance(bindingContext);

            object result;

            if (_handlerDelegate == null)
            {
                result = _handlerMethodInfo.Invoke(
                    invocationTarget,
                    invocationArguments);
            }
            else
            {
                result = _handlerDelegate.DynamicInvoke(invocationArguments);
            }

            return(await CommandHandler.GetResultCodeAsync(result, context));
        }
Exemplo n.º 3
0
        public async Task <int> InvokeAsync(InvocationContext context)
        {
            var bindingContext = context.BindingContext;

            var invocationTarget =
                _invocationTargetBinder?.CreateInstance(bindingContext);

            var invocationArguments =
                _parameterBinders.Select(p => p.CreateInstance(bindingContext))
                .ToArray();

            var result =
                _handlerDelegate == null
                    ? _handlerMethodInfo.Invoke(
                    invocationTarget,
                    invocationArguments)
                    : _handlerDelegate.DynamicInvoke(invocationArguments);

            return(await CommandHandler.GetResultCodeAsync(result, context));
        }
Exemplo n.º 4
0
        public Task <int> InvokeAsync(InvocationContext context)
        {
            var value = InvokeMethod(context);

            return(CommandHandler.GetResultCodeAsync(value, context));
        }