예제 #1
0
        private Task <Result <TData> > With <TData>(IWith <TData> with)
        {
            var pipelineType            = with.GetType();
            var withMultipleType        = typeof(WithMultiple <, ,>).MakeGenericType(pipelineType.GenericTypeArguments);
            var withMultipleHandlerType =
                typeof(WithMultipleHandler <, ,>).MakeGenericType(pipelineType.GenericTypeArguments);
            var withMultipleHandler = _serviceProvider.GetService(withMultipleHandlerType);

            var methodInfo = withMultipleHandlerType
                             .GetMethods(BindingFlags.Instance | BindingFlags.Public)
                             .Single(m => m.Name == nameof(IPipelineItemHandler <IPipeline> .ExecuteAsync));
            var withMultipleObj = Convert.ChangeType(with, withMultipleType);

            var invokeResult = methodInfo.Invoke(withMultipleHandler, new [] { withMultipleObj });

            return((Task <Result <TData> >)invokeResult);
        }