Ejemplo n.º 1
0
        public static async Task <TResult> Run <TResult>(this IProcessor processor, Bag args = null, IProcessorRunner runner = null)
        {
            args = args ?? new Bag();
            await processor.Run(args, runner).ConfigureAwait(false);

            return(args.ResultOrThrow <TResult>());
        }
        /// <summary>
        /// Runs a pipeline with <paramref name="args"/> context
        /// and <paramref name="runner"/>, and then returns a result.
        /// </summary>
        /// <typeparam name="TResult">
        /// The type of the result that is supposed to be returned from the method.
        /// </typeparam>
        /// <param name="pipeline">
        /// The pipeline to be executed. Each processor of this pipeline
        /// will be executed by <see cref="IPipelineRunner.Run{TArgs}"/>
        /// method with <paramref name="args"/> passed.
        /// </param>
        /// <param name="args">
        /// The context which will be passed to each processor of
        /// the pipeline during execution.
        /// </param>
        /// <param name="runner">
        /// The runner which will be used to run the wrapped pipeline.
        /// </param>
        /// <returns>
        /// The task object indicating the status of an executing pipeline.
        /// </returns>
        public static async Task <TResult> Run <TResult>(this IPipeline pipeline, Bag args = null, IPipelineRunner runner = null) where TResult : class
        {
            args = args ?? new Bag();
            await pipeline.Run(args, runner).ConfigureAwait(false);

            return(args.ResultOrThrow <TResult>());
        }
Ejemplo n.º 3
0
        public static async Task <TResult> Run <TResult>(this IProcessor processor, object args, IProcessorRunner runner = null)
        {
            if (!(args is Bag bag))
            {
                bag = new Bag(args);
            }
            await processor.Run(bag, runner).ConfigureAwait(false);

            return(bag.ResultOrThrow <TResult>());
        }
        public static async Task <TResult> Run <TResult>(this IPipeline pipeline, object args = null, IPipelineRunner runner = null) where TResult : class
        {
            if (!(args is Bag bag))
            {
                bag = new Bag(args);
            }
            await pipeline.Run(bag, runner).ConfigureAwait(false);

            return(bag.ResultOrThrow <TResult>());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Executes a method with predefined <see cref="Pipeline"/> and <see cref="Runner"/>.
        /// </summary>
        /// <typeparam name="TResult">
        /// The type of the result that is supposed to be returned from the method.
        /// </typeparam>
        /// <param name="arguments">
        /// The arguments that are passed to each executed processor in pipeline.
        /// </param>
        /// <returns>
        /// Returns a promise of the executed pipeline.
        /// </returns>
        public async Task <TResult> Run <TResult>(Bag arguments) where TResult : class
        {
            await this.Runner.Run(this.Pipeline, arguments).ConfigureAwait(false);

            return(arguments.ResultOrThrow <TResult>());
        }