/// <summary> /// Default-ctor to build an empty validation rule with given name, description and delegate /// </summary> internal RDFOntologyValidationRule(String ruleName, String ruleDescription, RuleDelegate ruleDelegate) { this.RuleName = ruleName; this.RuleDescription = ruleDescription; this.ExecuteRule = ruleDelegate; }
public Rule(Parser parser, RuleType ruleType, Predicate <Parser> lookAhead, RuleDelegate evaluate) { _parser = parser; _ruleType = ruleType; _lookAhead = lookAhead; _evaluate = evaluate; }
public static void FireEvent(RuleDelegate ruleEvent, object sender, RuleEventArgs args) { if (ruleEvent != null) { ruleEvent(sender, args); } }
public Rule(Parser parser, RuleType ruleType, Predicate<Parser> lookAhead, RuleDelegate evaluate) { _parser = parser; _ruleType = ruleType; _lookAhead = lookAhead; _evaluate = evaluate; }
/// <summary> /// We created a delegate to create a flexible behaviour /// </summary> public static void ScenarioOne() { RuleDelegate addDelegate = (x, y) => x + y; RuleDelegate multipleDelegate = (x, y) => x * y; var newOperation = new Calculator(); newOperation.Math(10, 10, multipleDelegate); newOperation.Math(10, 10, addDelegate); }
/// <summary> /// Creates new rule with parameters. /// </summary> /// <param name="templateName">String name of the template.</param> /// <param name="tag">String tag for which the rule will be applied to.</param> /// <param name="ruleDelegate">Rule delegate to be invoked to process the rule.</param> internal Rule(string templateName, string tag, RuleDelegate ruleDelegate) { this.TemplateName = templateName; this.Tag = tag; this.RuleDelegate = ruleDelegate; }
public static Rule Delay(RuleDelegate r) { return new DelayRule(r); }
public void Math(int x, int y, RuleDelegate del) { var result = del(x, y); System.Console.WriteLine(result); }
public virtual object ApplyOnce(object t, RuleDelegate whichRule) { originalAdaptor.ClearChanged(); if (t==null) return null; // Debug.Assert(this.BacktrackingLevel == 0); try { // Share TreeParser object but not parsing-related state // state = new RecognizerSharedState(); input = new CommonTreeNodeStream(originalAdaptor, t); ((CommonTreeNodeStream)input).TokenStream = originalTokenStream; // this.BacktrackingLevel = 1; // Debug.Assert(!this.Failed()); TreeRuleReturnScope r = whichRule((NadirAST)t); // return (r==null ? null : r.Tree); } catch (RecognitionException) { } finally { this.BacktrackingLevel = 0; } return t; }
/////////////////////////////////////////// // // Visitation // /////////////////////////////////////////// public override object ApplyOnce(object t, RuleDelegate whichRule) { object tNew = base.ApplyOnce(t, whichRule); // if (this.Failed() || !this.originalAdaptor.IsChanged()) { this.originalAdaptor.ClearChanged(); return t; } // if (showTransformations) { this.ReportTransformation(t, tNew); } // return tNew; }
/// <summary> /// Constructor. /// </summary> /// <param name="propertyName">The name of the property the rule is based on. This may be blank if the rule is not for any specific property.</param> /// <param name="brokenDescription">A description of the rule that will be shown if the rule is broken.</param> /// <param name="ruleDelegate"></param> public BusinessRule(string propertyName, string brokenDescription, RuleDelegate ruleDelegate) { this.Description = brokenDescription; this.PropertyName = propertyName; this.RuleDelegate = ruleDelegate; }
public static void FireEvent(RuleDelegate ruleEvent, object sender) { FireEvent(ruleEvent, sender, new RuleEventArgs()); }
/// <summary> /// Constructs a <c>DelegatedRule</c> with the given name and that /// applies in the circumstances defines by its <c>Precondition</c>. /// </summary> /// <param name="precondition">A <c>Precondition</c> instance.</param> /// <param name="name">The unique name for the rule.</param> /// <param name="function">The <see cref="RuleDelegate"/> delegate function.</param> public DelegatedRule(Precondition precondition, string name, RuleDelegate function) : base(precondition, name) { this.function = function; }
/// <summary> /// Constructs a <c>DelegatedRule</c> that applies to any document. /// </summary> /// <param name="name">The unique name for the rule.</param> /// <param name="function">The <see cref="RuleDelegate"/> delegate function.</param> public DelegatedRule(string name, RuleDelegate function) : base(name) { this.function = function; }
public static Rule Delay(string name, RuleDelegate r) { return(new RecursiveRule(name, r)); }
public RecursiveRule(string name, RuleDelegate deleg) { Debug.Assert(deleg != null); mName = name; mDeleg = deleg; }
public static void FireEvent(RuleDelegate ruleEvent, object sender) { FireEvent(ruleEvent, sender, new RuleEventArgs()); }
/// <summary> /// Constructs a <c>DelegatedRule</c> that applies to any document. /// </summary> /// <param name="name">The unique name for the rule.</param> /// <param name="function">The <see cref="RuleDelegate"/> delegate function.</param> public DelegatedRule(string name, RuleDelegate function) : base(name) { this.function = function; }
/// <summary> /// Constructs a <c>DelegatedRule</c> with the given name and that /// applies in the circumstances defines by its <c>Precondition</c>. /// </summary> /// <param name="precondition">A <c>Precondition</c> instance.</param> /// <param name="name">The unique name for the rule.</param> /// <param name="function">The <see cref="RuleDelegate"/> delegate function.</param> public DelegatedRule(Precondition precondition, string name, RuleDelegate function) : base(precondition, name) { this.function = function; }
public DelayRule(RuleDelegate deleg) { Trace.Assert(deleg != null); mDeleg = deleg; }
public static Rule Delay(RuleDelegate r) { return(new DelayRule(r)); }
public static Rule Delay(string name, RuleDelegate r) { return new RecursiveRule(name, r); }
public void AddRule(RuleDelegate rule) { this.Rules.Add(rule); }
/// <summary> /// Compute the automata for this cell /// </summary> /// <param name="ruleAppliesFor">The 'neighbor skipping rule' to apply</param> public void ComputeNextState(RuleDelegate ruleAppliesFor, bool randomize) { CellState nextState; for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { // Skip the middle cell (self) if (x == 0 && y == 0) continue; // Apply the skipping rule if (ruleAppliesFor(x, y)) continue; // Obtain this cell's neighbor at offset (x,y) from the grid Cell neighbor = grid.GetNeighborFor(this, x, y); // If any of the cell?s four ... neighbours has // the next state on from the cell nextState = state.nextState + (randomize? rand.Next(-1, 1) : 0); if (nextState == neighbor.state) { tempState = nextState; return; } } } // No rules were met; return the current state tempState = this.state; }
public virtual object ApplyRepeatedly(object t, RuleDelegate whichRule) { bool fChanged = true; while (fChanged && t != null) { t = ApplyOnce(t, whichRule); fChanged = this.originalAdaptor.IsChanged(); } // return t; }
public DelayRule(RuleDelegate deleg) { Trace.Assert(deleg != null); mDeleg = deleg; }
/// <summary> /// Adds new replacement rule to the template set. /// </summary> /// <param name="templateSet">Template set</param> /// <typeparam name="T">Template set class. Should be inherited from <see cref="AbstractTemplateSet"/>.</typeparam> /// <param name="template">Expression that defines template inside the template set. For example: ts => ts.Page.</param> /// <param name="tag">String tag for which the rule will be applied to.</param> /// <param name="rule">Rule that will be executed on specified template. All occurencies of tag will be replaced by returning value of the rule.</param> public static void AddRule <T>(this T templateSet, Expression <Func <T, string> > template, string tag, RuleDelegate rule) where T : AbstractTemplateSet { templateSet.ReplacementRules.Add(new Rule(templateSet.GetTemplateName(template), tag, rule)); }
public RecursiveRule(string name, RuleDelegate deleg) { Debug.Assert(deleg != null); mName = name; mDeleg = deleg; }