示例#1
0
 /// <summary>
 /// Executes the inner <see cref="IRule"/> and guards for
 /// a particular exception type.
 /// </summary>
 /// <param name="token">
 /// Authorization token
 /// </param>
 public void Produce(IProductionToken token)
 {
     try
     {
         this.rule.Produce(token.Production.RequestToken(this.rule));
     }
     catch (ProductionException)
     {
         return;
     }
     catch (Exception ex)
     {
         // check type
         if (!this.exceptionType.IsAssignableFrom(ex.GetType()))
         {
             throw new NotExpectedExceptionTypeException(exceptionType, ex);
         }
         // check message
         if (this.messageRegex != null)
         {
             if (!this.messageRegex.IsMatch(ex.Message))
             {
                 throw new NotExpectedMessageException(messageRegex, ex);
             }
         }
     }
     this.OnAction();
 }
示例#2
0
        /// <summary>
        /// Choose a <see cref="IRule"/> and launch its production.
        /// </summary>
        /// <param name="token">
        /// Authorizing token
        /// </param>
        public override void Produce(IProductionToken token)
        {
            IRule r = this.Selector.Select(this.Rules);

            r.Produce(token.Production.RequestToken(r));
            this.OnAction();
        }
示例#3
0
 /// <summary>
 /// Executes sub-rule production in sequence.
 /// </summary>
 /// <param name="token">
 /// <see cref="IProductionToken"/> to authorize production.
 /// </param>
 public override void Produce(IProductionToken token)
 {
     foreach (IRule r in this.Rules)
     {
         r.Produce(token.Production.RequestToken(r));
     }
     this.OnAction();
 }
示例#4
0
 public ProductionTokenEventArgs(IProductionToken token)
 {
     if (token == null)
     {
         throw new ArgumentNullException("token");
     }
     this.token = token;
 }
 /// <summary>
 /// Executes sub-rule production in sequence.
 /// </summary>
 /// <param name="token">
 /// <see cref="IProductionToken"/> to authorize production.
 /// </param>
 public override void Produce(IProductionToken token)
 {
     foreach(IRule r in this.Rules)
     {
         r.Produce(token.Production.RequestToken(r));
     }
     this.OnAction();
 }
示例#6
0
        /// <summary>
        /// Executes repeatidely the inner rule.
        /// </summary>
        /// <param name="token">
        /// Authorization token
        /// </param>
        public override void Produce(IProductionToken token)
        {
            int count = this.random.Next(this.minOccurence, this.maxOccurence);

            for (int i = 0; i < count; ++i)
            {
                this.Rule.Produce(token.Production.RequestToken(this.rule));
            }
            this.OnAction();
        }
示例#7
0
 /// <summary>
 /// Executes one of the rules depending on the predicate result.
 /// </summary>
 /// <param name="token">
 /// A production token authorizing production.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="token"/> is a null reference (Nothing in Visual Basic)
 /// </exception>
 public override void Produce(IProductionToken token)
 {
     if (this.predicate.Test(token))
     {
         this.Rule.Produce(token.Production.RequestToken(this.Rule));
     }
     else
     {
         if (this.ElseRule != null)
         {
             this.ElseRule.Produce(token.Production.RequestToken(this.ElseRule));
         }
     }
 }
示例#8
0
 public bool IsOrdersEmpty(IProductionToken token)
 {
     return(this.pop.Tables[this.db.Orders].Uniques.PrimaryKey.IsEmpty);
 }
示例#9
0
 public bool IsOrderAndProductEmpty(IProductionToken token)
 {
     return(IsOrdersEmpty(token) && IsProductsEmpty(token));
 }
示例#10
0
 /// <summary>
 /// Invokes the <see cref="MethodInvokerRule"/> instance.
 /// </summary>
 /// <param name="token">
 /// Autorization token
 /// </param>
 public override void Produce(IProductionToken token)
 {
     this.methodInvoker();
     this.OnAction();
 }
 public ProductionTokenEventArgs(IProductionToken token)
 {
     if (token==null)
         throw new ArgumentNullException("token");
     this.token=token;
 }
 /// <summary>
 /// Invokes the <see cref="ConditionDelegate"/> instance 
 /// and returns the result.
 /// </summary>
 /// <param name="token"></param>
 /// <returns></returns>
 public bool Test(IProductionToken token)
 {
     bool b =(bool)this.condition.DynamicInvoke(new Object[]{token});
     return b;
 }
示例#13
0
 public bool IsEmpty(IProductionToken token)
 {
     return(this.col.Count == 0);
 }
示例#14
0
 /// <summary>
 /// Invokes handler.
 /// </summary>
 /// <param name="token"></param>
 public override void Produce(IProductionToken token)
 {
     this.handler(this, EventArgs.Empty);
     this.OnAction();
 }
 /// <summary>
 /// Executes repeatidely the inner rule.
 /// </summary>
 /// <param name="token">
 /// Authorization token
 /// </param>
 public override void Produce(IProductionToken token)
 {
     int count = this.random.Next(this.minOccurence, this.maxOccurence);
     for(int i=0;i<count;++i)
     {
         this.Rule.Produce(token.Production.RequestToken(this.rule));
     }
     this.OnAction();
 }
 /// <summary>
 /// Choose a <see cref="IRule"/> and launch its production.
 /// </summary>
 /// <param name="token">
 /// Authorizing token
 /// </param>
 public override void Produce(IProductionToken token)
 {
     IRule r = this.Selector.Select(this.Rules);
     r.Produce(token.Production.RequestToken(r));
     this.OnAction();
 }
 /// <summary>
 /// Executes one of the rules depending on the predicate result.
 /// </summary>
 /// <param name="token">
 /// A production token authorizing production.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="token"/> is a null reference (Nothing in Visual Basic)
 /// </exception>
 public override void Produce(IProductionToken token)
 {
     if (this.predicate.Test(token))
         this.Rule.Produce(token.Production.RequestToken(this.Rule));
     else
     {
         if (this.ElseRule!=null)
             this.ElseRule.Produce(token.Production.RequestToken(this.ElseRule));
     }
 }
示例#18
0
 /// <summary>
 /// </summary>
 public override void Produce(IProductionToken token)
 {
     this.startRule.Produce(token.Production.RequestToken(this.startRule));
     this.OnAction();
 }
示例#19
0
 /// <summary>
 /// Executes the inner <see cref="IRule"/> and guards for
 /// a particular exception type.
 /// </summary>
 /// <param name="token">
 /// Authorization token
 /// </param>
 public void Produce(IProductionToken token)
 {
     try
     {
         this.rule.Produce(token.Production.RequestToken(this.rule));
     }
     catch(ProductionException)
     {
         return;
     }
     catch(Exception ex)
     {
         // check type
         if (!this.exceptionType.IsAssignableFrom(ex.GetType()))
             throw new NotExpectedExceptionTypeException(exceptionType,ex);
         // check message
         if (this.messageRegex!=null)
         {
             if (!this.messageRegex.IsMatch(ex.Message))
                 throw new NotExpectedMessageException(messageRegex,ex);
         }
     }
     this.OnAction();
 }
示例#20
0
 /// <summary>
 /// Executes the production using the rule (abstract class).
 /// </summary>
 /// <param name="token">
 /// A production token authorizing production.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="token"/> is a null reference (Nothing in Visual Basic)
 /// </exception>
 public abstract void Produce(IProductionToken token);
        /// <summary>
        /// Invokes the <see cref="ConditionDelegate"/> instance
        /// and returns the result.
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public bool Test(IProductionToken token)
        {
            bool b = (bool)this.condition.DynamicInvoke(new Object[] { token });

            return(b);
        }
 /// <summary>
 /// Invokes the <see cref="MethodInvokerRule"/> instance.
 /// </summary>
 /// <param name="token">
 /// Autorization token
 /// </param>
 public override void Produce(IProductionToken token)
 {
     this.methodInvoker();
     this.OnAction();
 }
 /// <summary>
 /// Invokes the <see cref="ProductionTokenDelegateRule"/> instance.
 /// </summary>
 /// <param name="token">
 /// Autorization token
 /// </param>
 public override void Produce(IProductionToken token)
 {
     this.productionTokenDelegate(token);
     this.OnAction();
 }
 /// <summary>
 /// Invokes the <see cref="ProductionTokenDelegateRule"/> instance.
 /// </summary>
 /// <param name="token">
 /// Autorization token
 /// </param>
 public override void Produce(IProductionToken token)
 {
     this.productionTokenDelegate(token);
     this.OnAction();
 }
示例#25
0
 /// <summary>
 /// </summary>
 public override void Produce(IProductionToken token)
 {
     this.startRule.Produce(token.Production.RequestToken(this.startRule));
     this.OnAction();
 }
示例#26
0
 /// <summary>
 /// Executes the production using the rule (abstract class).
 /// </summary>
 /// <param name="token">
 /// A production token authorizing production.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="token"/> is a null reference (Nothing in Visual Basic)
 /// </exception>
 public abstract void Produce(IProductionToken token);