Esempio n. 1
0
        /// <summary>
        ///     Create a new conditional processor with a given condition.
        ///     If the condition is <c>true</c>, <paramref name="dataProcessorA" /> will be used.
        ///     If the condition is <c>false</c>, <paramref name="dataProcessorB" /> will be used.
        ///     One of the two data processors may be <c>null</c> (but not both). If a given data processor is null, it will be not
        ///     be executed.
        /// </summary>
        /// <param name="condition">The condition that is used to evaluate. May not be <c>null</c>.</param>
        /// <param name="dataProcessorA">The data processor that is executed when the condition evaluates to <c>true</c>.</param>
        /// <param name="dataProcessorB">The data processor that is executed when the condition evaluates to <c>false</c>.</param>
        public ConditionalProcessor(Func <IFileSource, bool> condition, IDataProcessorOrBuilder dataProcessorA,
                                    IDataProcessorOrBuilder dataProcessorB)
        {
            if (dataProcessorA == null && dataProcessorB == null)
            {
                throw new ArgumentNullException(nameof(dataProcessorA), "Both parameters may not be null.");
            }

            _condition      = condition ?? throw new ArgumentNullException(nameof(condition));
            _dataProcessorA = dataProcessorA;
            _dataProcessorB = dataProcessorB;
        }
Esempio n. 2
0
        /// <summary>
        ///     Create a new multi processor (that acts like a nested pipeline) with given processors.
        /// </summary>
        /// <param name="processor">The first processor that will be executed. This one is required.</param>
        /// <param name="processors">The processors that will be managed and processed. May be <code>null</code> or empty.</param>
        public MultiProcessor(IDataProcessorOrBuilder processor, params IDataProcessorOrBuilder[] processors)
        {
            var dataProcessorOrBuilders = new IDataProcessorOrBuilder[(processors?.Length ?? 0) + 1];

            dataProcessorOrBuilders[0] = processor ?? throw new ArgumentNullException(nameof(processor));

            if (processors != null)
            {
                Array.Copy(processors, 0, dataProcessorOrBuilders, 1, processors.Length);
            }

            Processors = dataProcessorOrBuilders;
        }
        /// <summary>
        ///     Append a <see cref="IDataProcessor"/> (or builder). This can only be done, if the pipeline is not locked.
        /// </summary>
        /// <param name="dataProcessorOrBuilder">The processor or builder that will be added.</param>
        /// <returns>The builder itself.</returns>
        public IDataPipelineBuilder Append(IDataProcessorOrBuilder dataProcessorOrBuilder)
        {
            if (dataProcessorOrBuilder == null)
            {
                throw new ArgumentNullException(nameof(dataProcessorOrBuilder));
            }
            if (IsLocked)
            {
                throw new PipelineStateException("The pipeline is locked and cannot be modified.");
            }

            InternalPipeline.Add(dataProcessorOrBuilder);

            return(this);
        }
Esempio n. 4
0
 /// <summary>
 ///     Create a new conditional processor with a given condition.
 ///     If the condition is <c>true</c>, <paramref name="dataProcessorA" /> will be used and executed - otherwise nothing
 ///     will be executed.
 /// </summary>
 /// <param name="condition">The condition that is used to evaluate. May not be <c>null</c>.</param>
 /// <param name="dataProcessorA">
 ///     The data processor that is executed when the condition evaluates to <c>true</c>. May not
 ///     be <c>null</c>.
 /// </param>
 public ConditionalProcessor(Func <IFileSource, bool> condition, IDataProcessorOrBuilder dataProcessorA) : this(
         condition, dataProcessorA, null)
 {
 }
Esempio n. 5
0
 /// <summary>
 ///     Create a new debug processor that wraps the given data processor.
 /// </summary>
 /// <param name="dataProcessor">The data processor that will actually be executed.</param>
 public DebugProcessor(IDataProcessorOrBuilder dataProcessor)
 {
     DataProcessor = dataProcessor ?? throw new ArgumentNullException(nameof(dataProcessor));
 }