/// <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(); }
/// <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 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(); }
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(); }
/// <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> /// 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)); } } }
public bool IsOrdersEmpty(IProductionToken token) { return(this.pop.Tables[this.db.Orders].Uniques.PrimaryKey.IsEmpty); }
public bool IsOrderAndProductEmpty(IProductionToken token) { return(IsOrdersEmpty(token) && IsProductsEmpty(token)); }
/// <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; }
public bool IsEmpty(IProductionToken token) { return(this.col.Count == 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> /// 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)); } }
/// <summary> /// </summary> public override void Produce(IProductionToken token) { this.startRule.Produce(token.Production.RequestToken(this.startRule)); this.OnAction(); }
/// <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(); }
/// <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="ProductionTokenDelegateRule"/> instance. /// </summary> /// <param name="token"> /// Autorization token /// </param> public override void Produce(IProductionToken token) { this.productionTokenDelegate(token); this.OnAction(); }