public static Task Run(this IProcessor processor, object args, IProcessorRunner runner = null) { if (!(args is Bag bag)) { bag = new Bag(args); } return(processor.Run(bag, runner)); }
public static TResult RunSync <TResult>(this IProcessor processor, object args, IProcessorRunner runner = null) { return(processor.Run <TResult>(args, runner).Result); }
public static void RunSync(this IProcessor processor, object args, IProcessorRunner runner = null) { processor.Run(args, runner).Wait(); }
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 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 processor with <paramref name="args"/> context /// and <paramref name="runner"/>. /// </summary> /// <param name="processor"> /// The processor to be executed. It will be executed /// by <see cref="IProcessorRunner.Run{TArgs}"/> /// method with <paramref name="args"/> passed. /// </param> /// <param name="args"> /// The context which will be passed to the processor during execution. /// </param> /// <param name="runner"> /// The runner which will be used to run the processor. /// </param> /// <returns> /// The task object indicating the status of an executing pipeline. /// </returns> public static Task Run(this IProcessor processor, Bag args = null, IProcessorRunner runner = null) { runner = runner ?? Runner.Instance; args = args ?? new Bag(); return(runner.Run(processor, args)); }
/// <summary> /// Runs processors of <paramref name="enumerable"/> one by one /// with a specified <see cref="Runner"/> instance. /// </summary> /// <typeparam name="TArgs"> /// Type of arguments to be passed in each processor. /// </typeparam> /// <param name="enumerable"> /// Enumerable object of <see cref="IProcessor"/> to be /// executed one by one with a specified <see cref="Runner"/>. /// </param> /// <param name="args">Arguments to be passed in each processor.</param> /// <param name="runner"> /// Pipeline runner instance which will be used /// to execute collection of processors. /// </param> /// <returns> /// Returns <see cref="Task"/> object, which indicates a status /// of execution of processors. /// </returns> public static async Task Run(this IEnumerable <IProcessor> enumerable, Bag args, IProcessorRunner runner) { runner = runner ?? Runner.Instance; if (enumerable.HasNoValue()) { return; } foreach (var processor in enumerable) { await runner.Run(processor, args).ConfigureAwait(false); } }
public static async Task <TContext> Run <TContext>(this TContext context, IProcessor processor, IProcessorRunner runner = null) where TContext : Bag { await processor.Run(context, runner).ConfigureAwait(false); return(context); }
/// <summary> /// Creates a new pipeline runner with a custom <paramref name="processorRunner"/>. /// </summary> /// <param name="processorRunner"> /// Processor runner that defines how the processor should be executed. /// </param> public CustomRunner(IProcessorRunner processorRunner) { ProcessorRunner = processorRunner ?? throw new ArgumentNullException(nameof(processorRunner), ProcessorRunnerMustBeSpecified); }