Exemplo n.º 1
0
        /// <summary>
        /// Adds the stop condition to the chain and ties it to the chain with specified
        /// operator.
        /// </summary>
        /// <param name="anotherStopCondition">Another stop condition.</param>
        /// <param name="mode">The mode (operator).</param>
        /// <returns>Stop condition chain with added <paramref name="anotherStopCondition"/>.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException"> if <paramref name="mode"/>
        /// differs from one of the supported operations or is the default one.</exception>
        /// <exception cref="System.InvalidOperationException"> if trying to add new stop condition
        /// with the operator that differs from previous ones.</exception>
        private StopConditionChain AddStopCondition(IStopCondition anotherStopCondition, StopConditionChain.AggregationOperator mode)
        {
            if (mode == StopConditionChain.AggregationOperator.None)
            {
                throw new ArgumentOutOfRangeException(nameof(mode));
            }

            if (this.aggregationMode == StopConditionChain.AggregationOperator.None)
            {
                this.aggregationMode = mode;
            }

            if (this.aggregationMode != mode)
            {
                throw new InvalidOperationException();
            }

            Debug.Assert(this.stopConditions != null, "Stop condition collection is null");

            this.stopConditions.Add(anotherStopCondition);
            return(this);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Prevents a default instance of the <see cref="StopConditionChain"/>
 /// class from being created.
 /// </summary>
 private StopConditionChain()
 {
     this.stopConditions  = new List <IStopCondition>();
     this.aggregationMode = StopConditionChain.AggregationOperator.None;
 }