private void ExecutePipeLineStep(IPipelineStep pipelineStep, PropertyBag propertyBag) { try { Stopwatch sw = Stopwatch.StartNew(); m_Logger.Debug("Executing pipeline step {0}", pipelineStep.GetType().Name); if (pipelineStep is IPipelineStepWithTimeout) { IPipelineStepWithTimeout stepWithTimeout = (IPipelineStepWithTimeout)pipelineStep; m_Logger.Debug("Running pipeline step {0} with timeout {1}", pipelineStep.GetType().Name, stepWithTimeout.ProcessorTimeout); m_TaskRunner.RunSync(cancelArgs => { if (!cancelArgs.Cancel) { pipelineStep.Process(this, propertyBag); } }, stepWithTimeout.ProcessorTimeout); } else { pipelineStep.Process(this, propertyBag); } m_Logger.Debug("Executed pipeline step {0} in {1}", pipelineStep.GetType().Name, sw.Elapsed); } catch (Exception ex) { OnProcessorException(propertyBag, ex); } }
/// <summary> /// Add a step to process the input and transform it into an output /// </summary> /// <param name="input">Input</param> /// <typeparam name="TInput">Type of the input</typeparam> /// <param name="step">Pipeline step</param> /// <typeparam name="TOutput">Type of the output</typeparam> /// <param name="arg1">Additional argument passed to the process</param> /// <typeparam name="TArg1">Type of the first argument</typeparam> /// <param name="arg2">Additional argument passed to the process</param> /// <typeparam name="TArg1">Type of the second argument</typeparam> /// <param name="arg3">Additional argument passed to the process</param> /// <typeparam name="TArg3">Type of the third argument</typeparam> /// <returns>Returns the output of processing the input</returns> public static TOutput AddStep <TInput, TArg1, TArg2, TArg3, TOutput>( this TInput input, IPipelineStep <TInput, TArg1, TArg2, TArg3, TOutput> step, TArg1 arg1, TArg2 arg2, TArg3 arg3) { return(step.Process(input, arg1, arg2, arg3)); }
public OUTPUT Process(INPUT input) { OnInput?.Invoke(input); var output = _innerStep.Process(input); OnOutput?.Invoke(output); return(output); }
public static INPUTOUTPUT Step <INPUTOUTPUT>(this INPUTOUTPUT input, IPipelineStep <INPUTOUTPUT> step) { if (step == null) { return(input); } return(step.Process(input)); }
/// <summary> /// The process that invokes the step and optionally invokes pre and post actions /// </summary> /// <param name="input"></param> /// <returns></returns> public TOutput Process(TInput input) { OnInput?.Invoke(input); var output = _innerStep.Process(input); OnOutput?.Invoke(output); return(output); }
public OUTPUT Process(INPUT input) { if (_choice(input)) { return(_first.Process(input)); } else { return(_second.Process(input)); } }
public OUTPUT Process(INPUT input) { if (_choice(input)) { return(_step.Process(input)); } else { return(input); } }
public IEnumerable <OUTPUT> Process(IEnumerable <INPUT> input) { foreach (INPUT item in input) { yield return(_internalStep.Process(item)); } //等价于下述代码段 //return from INPUT item in input // select _internalStep.Process(item); }
public static OUTPUT Step <INPUT, OUTPUT>(this INPUT input, IPipelineStep <INPUT, OUTPUT> step, Action <INPUT> inputEvent = null, Action <OUTPUT> outputEvent = null) { if (inputEvent != null || outputEvent != null) { var eventDecorator = new EventStep <INPUT, OUTPUT>(step); eventDecorator.OnInput += inputEvent; eventDecorator.OnOutput += outputEvent; return(eventDecorator.Process(input)); } return(step.Process(input)); }
private void ExecutePipeLineStep(IPipelineStep pipelineStep, PropertyBag propertyBag) { try { if (pipelineStep is IPipelineStepWithTimeout) { IPipelineStepWithTimeout stepWithTimeout = (IPipelineStepWithTimeout)pipelineStep; m_Logger.Debug("Running pipeline step {0} with timeout {1}", pipelineStep.GetType().Name, stepWithTimeout.ProcessorTimeout); m_TaskRunner.RunSync(() => pipelineStep.Process(this, propertyBag), stepWithTimeout.ProcessorTimeout); } else { m_Logger.Debug("Running pipeline step {0}", pipelineStep.GetType().Name); pipelineStep.Process(this, propertyBag); } } catch (Exception ex) { OnProcessorException(propertyBag, ex); } }
public ActionResult <float> Get(int id) { var request = new HubRequest { Id = id, Properties = new string[] { "1", "2", "3", "4", "5", "6" } }; _logger.LogInformation("Input '{value}' [{type}]", request, request.GetType().Name); var response = _pipeline.Process(request); _logger.LogInformation("Output '{value}' [{type}]", response, request.GetType().Name); return(Ok(response)); }
internal static PipelineContinuation <TOut> Then <T, TOut>(this PipelineContinuation <T> @this, IPipelineStep <T, TOut> nextStep) { switch (@this.Action) { case PipelineContinuationAction.Abort: case PipelineContinuationAction.Terminate: throw new PipelineAbortException() { Result = @this.Result }; default: return(nextStep.Process(@this.Result)); } }
public static TOutput Step <TInput, TOutput>(this TInput input, IPipelineStep <TInput, TOutput> step) { return(step.Process(input)); }
private void ExecutePipeLineStep(IPipelineStep pipelineStep, PropertyBag propertyBag) { try { if (pipelineStep is IPipelineStepWithTimeout) { IPipelineStepWithTimeout stepWithTimeout = (IPipelineStepWithTimeout) pipelineStep; m_Logger.Debug("Running pipeline step {0} with timeout {1}", pipelineStep.GetType().Name, stepWithTimeout.ProcessorTimeout); m_TaskRunner.RunSync(() => pipelineStep.Process(this, propertyBag), stepWithTimeout.ProcessorTimeout); } else { m_Logger.Debug("Running pipeline step {0}", pipelineStep.GetType().Name); pipelineStep.Process(this, propertyBag); } } catch (Exception ex) { OnProcessorException(propertyBag, ex); } }
public static OUTPUT Step <INPUT, OUTPUT>(this INPUT input, IPipelineStep <INPUT, OUTPUT> step) { return(step.Process(input)); }
public OUTPUT Process(INPUT input) { return(_choice(input) ? _step.Process(input) : input); }
private void ExecutePipeLineStep(IPipelineStep pipelineStep, PropertyBag propertyBag) { try { Stopwatch sw = Stopwatch.StartNew(); m_Logger.Debug("Executing pipeline step {0}", pipelineStep.GetType().Name); if (pipelineStep is IPipelineStepWithTimeout) { IPipelineStepWithTimeout stepWithTimeout = (IPipelineStepWithTimeout) pipelineStep; m_Logger.Debug("Running pipeline step {0} with timeout {1}", pipelineStep.GetType().Name, stepWithTimeout.ProcessorTimeout); m_TaskRunner.RunSync(cancelArgs => { if (!cancelArgs.Cancel) { pipelineStep.Process(this, propertyBag); } }, stepWithTimeout.ProcessorTimeout); } else { pipelineStep.Process(this, propertyBag); } m_Logger.Debug("Executed pipeline step {0} in {1}", pipelineStep.GetType().Name, sw.Elapsed); } catch (Exception ex) { OnProcessorException(propertyBag, ex); } }