コード例 #1
0
        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));
        }
コード例 #2
0
        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 ??
                                       bindingContext.ServiceProvider.GetService(_handlerMethodInfo !.DeclaringType);
                if (invocationTarget is { })