Exemplo n.º 1
0
 private ChainedWaterfall(ChainedWaterfall <TInput, TResult> current, IWaterfall <TInput, TResult> nextWaterfall)
 {
     if (nextWaterfall == null)
     {
         throw new ArgumentNullException(nameof(nextWaterfall));
     }
     _waterfall = new IWaterfall <TInput, TResult> [current._waterfall.Length + 1];
     for (var index = 0; index < current._waterfall.Length; index++)
     {
         _waterfall[index] = current._waterfall[index];
     }
     _waterfall[current._waterfall.Length] = nextWaterfall;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Default Ctor.
 /// </summary>
 /// <param name="waterfallHead">First link in the waterfall chain, i.e. execution will start at this waterfall.</param>
 /// <param name="nextWaterfall">Next waterfall in the chain.</param>
 public ChainedWaterfall(IWaterfall <TInput, TResult> waterfallHead, IWaterfall <TInput, TResult> nextWaterfall)
 {
     if (waterfallHead == null)
     {
         throw new ArgumentNullException(nameof(waterfallHead));
     }
     if (nextWaterfall == null)
     {
         throw new ArgumentNullException(nameof(nextWaterfall));
     }
     _waterfall    = new IWaterfall <TInput, TResult> [2];
     _waterfall[0] = waterfallHead;
     _waterfall[1] = nextWaterfall;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Default Ctor.
 /// </summary>
 /// <param name="firstWaterfall">Instance of waterfall</param>
 /// <param name="anotherWaterfall">Another instance of waterfall</param>
 public ConcurrentWaterfall(IWaterfall <TInput, TResult> firstWaterfall,
                            IWaterfall <TInput, TResult> anotherWaterfall)
 {
     if (firstWaterfall == null)
     {
         throw new ArgumentNullException(nameof(firstWaterfall));
     }
     if (anotherWaterfall == null)
     {
         throw new ArgumentNullException(nameof(anotherWaterfall));
     }
     _waterfall    = new IWaterfall <TInput, TResult> [2];
     _waterfall[0] = firstWaterfall;
     _waterfall[1] = anotherWaterfall;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Default Ctor.
        /// </summary>
        /// <param name="waterfall">Waterfall to execute. This can be enum/int based standalone waterfall OR
        /// Chained/Concurrent waterfall.</param>
        /// <param name="outcomeHandler">Outcome handler</param>
        /// <param name="errorHandler">Error handler</param>
        public WaterfallService(IWaterfall <TInput, TResult> waterfall, Action <TInput, TResult> outcomeHandler,
                                Action <TInput, TResult, Exception> errorHandler)
        {
            if (waterfall == null)
            {
                throw new ArgumentNullException(nameof(waterfall));
            }
            if (outcomeHandler == null)
            {
                throw new ArgumentNullException(nameof(outcomeHandler));
            }
            if (errorHandler == null)
            {
                throw new ArgumentNullException(nameof(errorHandler));
            }

            _waterfall      = waterfall;
            _outcomeHandler = outcomeHandler;
            _errorHandler   = errorHandler;
        }
Exemplo n.º 5
0
 /// <summary>
 /// Adds new waterfall in the collection to be executed in parallel
 /// </summary>
 /// <param name="anotherWaterfall">Waterfall to be added in the collection for parallel processing</param>
 /// <returns>New instance of the class</returns>
 public ConcurrentWaterfall <TInput, TResult> Add(IWaterfall <TInput, TResult> anotherWaterfall)
 {
     return(new ConcurrentWaterfall <TInput, TResult>(this, anotherWaterfall));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Extends the chain by adding the given waterfall at the end of the existing chain.
 /// </summary>
 /// <param name="nextWaterfall">Waterfall to be added at the end of processing chain.</param>
 /// <returns>New instance of the class</returns>
 public ChainedWaterfall <TInput, TResult> Add(IWaterfall <TInput, TResult> nextWaterfall)
 {
     return(new ChainedWaterfall <TInput, TResult>(this, nextWaterfall));
 }