示例#1
0
 /// <summary>
 /// Runs processors of <paramref name="enumerable"/> one by one
 /// with a default <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 default <see cref="Runner"/>.
 /// </param>
 /// <param name="args">Arguments to be passed in each processor.</param>
 /// <returns>
 /// Returns <see cref="Task"/> object, which indicates a status
 /// of execution of processors.
 /// </returns>
 public static Task Run(this IEnumerable <IProcessor> enumerable, Bag args)
 {
     return(enumerable.Run(args, Runner.Instance));
 }
 /// <summary>
 /// Runs a pipeline with <paramref name="args"/> context
 /// and <paramref name="runner"/> synchronously, waiting until
 /// all processors of the pipeline will be executed
 /// 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 TResult RunSync <TResult>(this IPipeline pipeline, Bag args = null, IPipelineRunner runner = null) where TResult : class
 {
     return(pipeline.Run <TResult>(args, runner).Result);
 }
 /// <summary>
 /// Runs a pipeline with <paramref name="args"/> context
 /// and <paramref name="runner"/>.
 /// </summary>
 /// <typeparam name="TContext">
 /// The type of the context that is used during pipeline execution.
 /// </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 Task Run(this IPipeline pipeline, Bag args = null, IPipelineRunner runner = null)
 {
     runner = runner ?? Runner.Instance;
     args   = args ?? new Bag();
     return(runner.Run(pipeline, args));
 }
 /// <summary>
 /// Runs a pipeline with <paramref name="args"/> context
 /// and <paramref name="runner"/> synchronously, waiting until
 /// all processors of the pipeline will be executed.
 /// </summary>
 /// <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>
 public static void RunSync(this IPipeline pipeline, Bag args = null, IPipelineRunner runner = null)
 {
     pipeline.Run(args, runner).Wait();
 }
 public static TValue Map <TValue>(this Bag bag, LambdaExpression expression) where TValue : class
 {
     return(bag.Map(expression) as TValue);
 }
 public static object Map <TProperty>(this Bag bag, Expression <Func <TProperty, object> > expression)
 {
     return(bag.Map((LambdaExpression)expression));
 }
 public static TResult Map <TProperty, TResult>(this Bag bag, Expression <Func <TProperty, object> > expression) where TResult : class
 {
     return(bag.Map((LambdaExpression)expression) as TResult);
 }
 internal static IDictionary <Type, object> GetSingleTypeValues(this Bag context)
 {
     return(context.GroupBy(x => x.Value.GetType()).Where(x => x.Count() == 1).ToDictionary(x => x.Key, x => x.First().Value));
 }