• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Rule类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Rule的典型用法代码示例。如果您正苦于以下问题:C# Rule类的具体用法?C# Rule怎么用?C# Rule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Rule类属于命名空间,在下文中一共展示了Rule类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AsmBaseGrammar

        public AsmBaseGrammar()
        {
            space = CharSeq(" ");
            tab = CharSeq("\t");
            simple_ws = space | tab;
            eol = Opt(CharSeq("\r")) + CharSeq("\n");
            multiline_ws = simple_ws | eol;
            ws = Eat(multiline_ws);
            digit = CharRange('0', '9');
            number = Leaf(Plus(digit));
            lower_case_letter = CharRange('a', 'z');
            upper_case_letter = CharRange('A', 'Z');
            letter = lower_case_letter | upper_case_letter;
            sign = CharSet("$-");

            opcode = Leaf(letter + Star(letter));
            register = Leaf(CharSeq("r") + Plus(digit));
            memoryAddress = CharSeq("[") + register + CharSeq("]");
            constant = sign + number;
            operand = register | memoryAddress | constant;
            comment_content = Leaf(Star(AnythingBut(eol)));
            comment = CharSet(";") + comment_content;

            InitializeRules<AsmBaseGrammar>();
        }
开发者ID:andy-uq,项目名称:TinyOS,代码行数:25,代码来源:AsmBaseGrammar.cs


示例2: Tamagotchi_Dead_DoNothing

        public void Tamagotchi_Dead_DoNothing()
        {
            var rules = new Rule[]
            {
                new AthleticRule(),
                new BordedomRule(),
                new CrazinessRule(),
                new FatigueRule(),
                new HungerRule(),
                new IsolationRule(),
                new MuchiesRule(),
                new SleepDeprivationRule(),
                new StarvationRule()
            };

            rules = rules.OrderBy(r => r.Order).ToArray();

            Tamagotchi t1 = new Tamagotchi("test", rules);

            t1.HasDied = true;

            var now = DateTime.UtcNow + TimeSpan.FromHours(2);

            Assert.IsFalse(t1.EatAction(now));
            Assert.IsFalse(t1.RefreshRules(now));

            Assert.AreNotEqual(t1.LastAllRulesPassedUtc, now);
        }
开发者ID:Netvon,项目名称:Tamagotchi,代码行数:28,代码来源:TamagotchiRules.cs


示例3: Define_rule

        public void Define_rule()
        {
            var conditions = new RuleCondition[]
                {
                    Conditions.Equal((Order x) => x.Name, "JOE"),
                    Conditions.GreaterThan((Order x) => x.Amount, 10000.0m),
                };

            var consequences = new RuleConsequence[]
                {
                    Consequences.Delegate<Order>((session,x) => { _result = x; }),
                    Consequences.Delegate<Order>((session,x) => { _resultB = x; }),
                };

            _rule = new OdoyuleRule("RuleA", conditions, consequences);
            _rule2 = new OdoyuleRule("RuleB", conditions, consequences);

            conditions = new RuleCondition[]
                {
                    Conditions.Equal((Account a) => a.Name, "JOE"),
                };

            consequences = new RuleConsequence[]
                {
                    Consequences.Delegate((Session session, Account a) => { }),
                };

            _rule3 = new OdoyuleRule("RuleC", conditions, consequences);
        }
开发者ID:drusellers,项目名称:Odoyule,代码行数:29,代码来源:Declaration_Specs.cs


示例4: FileEntry

 /* public PackageAssembly(string assemblyName, Rule rule ,string filename ) {
     Name = assemblyName;
     Rule = rule;
     _files = new FileEntry(filename, Path.GetFileName(filename)).SingleItemAsEnumerable();
 } */
 public PackageAssembly(string assemblyName, Rule rule, IEnumerable<string> files)
 {
     Name = assemblyName;
     Rule = rule;
     // when given just filenames, strip the
     _files = files.Select(each => new FileEntry(each, Path.GetFileName(each)));
 }
开发者ID:virmitio,项目名称:devtools,代码行数:12,代码来源:PackageAssembly.cs


示例5: Validate

        public bool Validate(out string validateMessage, out Rule rule)
        {
            bool result = true;
            rule = new Rule();

            validateMessage = "Rule Ok";

            if (m_ConditionContainer.m_ConditionList.Count > 0)
            {
                GraphToRule converter = new GraphToRule(m_TargetObject.GetComponent<State>() as State);

                rule.m_Rule = converter.Convert(m_Rule.m_Name, m_ConditionContainer.m_ConditionList[0], m_ActionContainer.m_ActionList);
                rule.SetContext(m_TargetObject.GetComponent<InferenceEngine>() as InferenceEngine);

                try
                {
                    result = rule.Validate();
                }
                catch (InvalidRuleException e)
                {
                    Debug.Log (e.Message);
                    validateMessage = e.Message;
                }
            }

            return result;
        }
开发者ID:Exospector,项目名称:Cthulours,代码行数:27,代码来源:RuleInspector.cs


示例6: GetRulePreview

        static internal string GetRulePreview(Rule rule)
        {
            StringBuilder rulePreview = new StringBuilder();

            if (rule != null)
            {
                rulePreview.Append("IF ");
                if (rule.Condition != null)
                    rulePreview.Append(rule.Condition.ToString() + " ");
                rulePreview.Append("THEN ");

                foreach (RuleAction action in rule.ThenActions)
                {
                    rulePreview.Append(action.ToString());
                    rulePreview.Append(' ');
                }

                if (rule.ElseActions.Count > 0)
                {
                    rulePreview.Append("ELSE ");
                    foreach (RuleAction action in rule.ElseActions)
                    {
                        rulePreview.Append(action.ToString());
                        rulePreview.Append(' ');
                    }
                }
            }

            return rulePreview.ToString();
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:30,代码来源:DesignerHelpers.cs


示例7: Main

        static void Main(string[] args) {
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            if (args.Length < 3) {
                help();
                return;
            }
            String source_dir = args[1].Replace("\"", "");
            String target_dir = args[2].Replace("\"", "");

            XmlDocument xml_rules = new XmlDocument();
            xml_rules.Load(args[0]);

        //read list of languages that should be ignored or renamed
            Dictionary<String, String> langs = new Dictionary<String, String>();
            foreach (XmlNode node in xml_rules.SelectNodes("//lang")) {
                langs.Add( node.SelectSingleNode("@id").InnerText,  node.SelectSingleNode("@renameTo").InnerText);
            }

        //read list of rules and apply each rule
            foreach (XmlNode node in xml_rules.SelectNodes("//rule")) {
                Rule r = new Rule(node);
                StringBuilder sb = new StringBuilder();
                apply_rule(r, source_dir, target_dir, langs, sb);
                Console.WriteLine(sb.ToString());
            }
        }
开发者ID:bravesoftdz,项目名称:dvsrc,代码行数:26,代码来源:Program.cs


示例8: SetPendingInvocation

 internal bool SetPendingInvocation(Rule rule, bool isPending)
 {
     if (isPending)
         return pendingInvocation.Add(rule);
     else
         return pendingInvocation.Remove(rule);
 }
开发者ID:vc3,项目名称:ExoRule,代码行数:7,代码来源:RuleManager.cs


示例9: Start

	// Use this for initialization
	void Start ()
	{

		Board board = new Board(3,3);
		board.SetPiece(0,0, Piece.DiePiece("One","White"));
		board.SetPiece(0,1, Piece.DiePiece("Two","White"));
		board.SetPiece(0,2, Piece.DiePiece("Three", "Black"));

		Rule rule1 = new Rule(new AllHave(new PropertyCheckers.PropertyHasValue("Face","One")));
		Rule rule2 = new Rule(new ExistsOneHas(new PropertyCheckers.PropertyHasValue("Face","One")));
		Rule rule3 = new Rule(new AllHave(new PropertyCheckers.Not(new PropertyCheckers.PropertyHasValue("Colour","Blue"))));
		Rule rule4 = new Rule(new FaceSum(new Comparers<int>.LessThan(), 7));
		Rule rule5 = new Rule(new PropertyCount(new PropertyCheckers.PropertyHasValue("Face","One"),new Comparers<int>.Equal(), 1));

		System.Diagnostics.Debug.Assert(rule1.Evaluate(board) == false);
		System.Diagnostics.Debug.Assert(rule2.Evaluate(board) == true);
		System.Diagnostics.Debug.Assert(rule3.Evaluate(board) == true);
		System.Diagnostics.Debug.Assert(rule4.Evaluate(board) == true);
		System.Diagnostics.Debug.Assert(rule5.Evaluate(board) == true);

		Debug.Log (rule1.ToString());

		rule2.And(rule4);
		Debug.Log (rule2.ToString());
		Rule rule6 = new Rule(new ExistsOneHas(new PropertyCheckers.PropertyHasValue("Face","One")));
		Rule rule7 = new Rule(new FaceSum(new Comparers<int>.LessThan(), 7));
		rule6.And(rule7);
		Debug.Log (rule6.ToString());


		System.Diagnostics.Debug.Assert(rule2.Evaluate(board) == true);
	}
开发者ID:EternalGB,项目名称:Enlightenment,代码行数:33,代码来源:DieTest.cs


示例10: AddToBehavior

 public AddToBehavior(string name, Type type, Spec spec, Rule rule)
 {
     Name = name;
     Type = type;
     Spec = spec;
     Rule = rule;
 }
开发者ID:civicacid,项目名称:myevo,代码行数:7,代码来源:AddToBehavior.cs


示例11: AddCondition

 private void AddCondition(Rule rule, AdvTree advTree)
 {
     var node = new Node();
     node.Text = rule.Name;
     node.Tag = rule;
     AddNode(node, advTree);
 }
开发者ID:civicacid,项目名称:myevo,代码行数:7,代码来源:RotationForm.cs


示例12: compileFirstJoin

 /// <summary> TODO - note the logic feels a bit messy. Need to rethink it and make it
 /// simpler. When the first conditional element is Exist, it can only have
 /// literal constraints, so we shouldn't need to check if the last node
 /// is a join. That doesn't make any sense. Need to rethink this and clean
 /// it up. Peter Lin 10/14/2007
 /// </summary>
 public override void compileFirstJoin(ICondition condition, Rule.IRule rule)
 {
     BaseJoin bjoin = new ExistJoinFrst(ruleCompiler.Engine.nextNodeId());
     ExistCondition cond = (ExistCondition) condition;
     BaseNode base_Renamed = cond.LastNode;
     if (base_Renamed != null)
     {
         if (base_Renamed is BaseAlpha)
         {
             ((BaseAlpha) base_Renamed).addSuccessorNode(bjoin, ruleCompiler.Engine, ruleCompiler.Memory);
         }
         else if (base_Renamed is BaseJoin)
         {
             ((BaseJoin) base_Renamed).addSuccessorNode(bjoin, ruleCompiler.Engine, ruleCompiler.Memory);
         }
     }
     else
     {
         // the rule doesn't have a literal constraint so we need to Add
         // ExistJoinFrst as a child
         ObjectTypeNode otn = ruleCompiler.findObjectTypeNode(cond.TemplateName);
         otn.addSuccessorNode(bjoin, ruleCompiler.Engine, ruleCompiler.Memory);
     }
     // important, do not call this before ExistJoinFrst is added
     // if it's called first, the List<Object> will return index
     // out of bound, since there's nothing in the list
     cond.addNode(bjoin);
 }
开发者ID:,项目名称:,代码行数:34,代码来源:


示例13: compileJoin

 /// <summary> the method is responsible for compiling a TestCE pattern to a testjoin node.
 /// It uses the globally declared prevCE and prevJoinNode
 /// </summary>
 public virtual BaseJoin compileJoin(ICondition condition, int position, Rule.IRule rule)
 {
     TestCondition tc = (TestCondition) condition;
     ShellFunction fn = (ShellFunction) tc.Function;
     fn.lookUpFunction(ruleCompiler.Engine);
     IParameter[] oldpm = fn.Parameters;
     IParameter[] pms = new IParameter[oldpm.Length];
     for (int ipm = 0; ipm < pms.Length; ipm++)
     {
         if (oldpm[ipm] is ValueParam)
         {
             pms[ipm] = ((ValueParam) oldpm[ipm]).cloneParameter();
         }
         else if (oldpm[ipm] is BoundParam)
         {
             BoundParam bpm = (BoundParam) oldpm[ipm];
             // now we need to resolve and setup the BoundParam
             Binding b = rule.getBinding(bpm.VariableName);
             BoundParam newpm = new BoundParam(b.LeftRow, b.LeftIndex, 9, bpm.ObjectBinding);
             newpm.VariableName = bpm.VariableName;
             pms[ipm] = newpm;
         }
     }
     BaseJoin joinNode = null;
     if (tc.Negated)
     {
         joinNode = new NTestNode(ruleCompiler.Engine.nextNodeId(), fn.Function, pms);
     }
     else
     {
         joinNode = new TestNode(ruleCompiler.Engine.nextNodeId(), fn.Function, pms);
     }
     ((TestNode) joinNode).lookUpFunction(ruleCompiler.Engine);
     return joinNode;
 }
开发者ID:,项目名称:,代码行数:38,代码来源:


示例14: AddRule

 public void AddRule(Rule rule)
 {
     lock (_rules)
     {
         _rules.Add(rule);
     }
 }
开发者ID:civicacid,项目名称:myevo,代码行数:7,代码来源:RuleController.cs


示例15: FilterCustomers

        private static IQueryable<Customer> FilterCustomers(IQueryable<Customer> customers, Rule rule)
        {
            switch (rule.field)
            {
                case "CustomerId":
                    return customers.Where(c => c.CustomerId == rule.data);

                case "Name":
                    return customers.Where(c => c.Fullname.ToLower().Contains(rule.data.ToLower()));

                case "Company":
                    return customers.Where(c => c.Company.ToLower().Contains(rule.data.ToLower()));

                case "EmailAddress":
                    return customers.Where(c => c.EmailAddress.ToLower().Contains(rule.data.ToLower()));

                case "Last Modified":
                    DateTime dateResult;
                    return !DateTime.TryParse(rule.data, out dateResult) ? customers : customers.Where(c => c.LastModified.Date == dateResult.Date);

                case "Telephone":
                    return customers.Where(c => c.Telephone.ToLower().Contains(rule.data.ToLower()));

                default:
                    return customers;
            }
        }
开发者ID:Janvanderheide,项目名称:MvcJqGrid,代码行数:27,代码来源:Repository.cs


示例16: Simple_When_is_a_predicate_for_evaluting_the_Condition

 public void Simple_When_is_a_predicate_for_evaluting_the_Condition()
 {
     IRule<Customer> rule = new Rule<Customer>();
     rule.When(p => p.PurchasedAmount >= 10000);
     rule.Then(p => p.customerType = CustomerType.Normal);
     rule.Execute(new Customer { PurchasedAmount = 100001 }).customerType.Should().Be(CustomerType.Normal);
 }
开发者ID:satish860,项目名称:RuleComposer,代码行数:7,代码来源:RuleTest.cs


示例17: OrderRouter

 private OrderRouter()
 {
     routeRules = Rule.Create<OrderModel>(o => o.Status == OrderStatus.New, o => Route())
                      .Add(o => o.Status == OrderStatus.NameChosen, o => container.Add(new OrderView(new OrderViewModel(o))))
                      .Add(o => o.Status == OrderStatus.ItemsSelected, o => container.Add(new CheckoutView(new CheckoutViewModel(o))))
                      .Add(o => o.Status == OrderStatus.Submitted, o => container.Add(new CompleteView(new CompleteViewModel(o))));
 }
开发者ID:kodefuguru,项目名称:Presentations,代码行数:7,代码来源:OrderRouter.cs


示例18: LSystem

    // Constructor
    public LSystem(string _axiom, Rule[] ruleset)
    {
        rules = ruleset;
        generation = 0;

        alphabet = _axiom;
    }
开发者ID:Matzkee,项目名称:GameEngines1Assignment,代码行数:8,代码来源:LSystem.cs


示例19: TranslateRuleCode

 /* zCode is a string that is the action associated with a rule.  Expand the symbols in this string so that the refer to elements of the parser stack. */
 private static void TranslateRuleCode(Context ctx, Rule rule)
 {
     var used = new bool[rule.RHSymbols.Length]; /* True for each RHS element which is used */
     var lhsused = false; /* True if the LHS element has been used */
     if (rule.Code == null) { rule.Code = "\n"; rule.Lineno = rule.RuleLineno; }
     var b = new StringBuilder();
     var z = rule.Code;
     for (var cp = 0; cp < z.Length; cp++)
     {
         if (char.IsLetter(z[cp]) && (cp == 0 || (!char.IsLetterOrDigit(z[cp - 1]) && z[cp - 1] != '_')))
         {
             var xp = cp + 1;
             for (; char.IsLetterOrDigit(z[xp]) || z[xp] == '_'; xp++) ;
             //var saved = z[xp];
             var xpLength = xp - cp;
             if (rule.LHSymbolAlias != null && z.Substring(cp, xpLength) == rule.LHSymbolAlias)
             {
                 b.AppendFormat("yygotominor.yy{0}", rule.LHSymbol.DataTypeID);
                 cp = xp;
                 lhsused = true;
             }
             else
             {
                 for (var i = 0; i < rule.RHSymbols.Length; i++)
                     if (rule.RHSymbolsAlias[i] != null && z.Substring(cp, xpLength) == rule.RHSymbolsAlias[i])
                     {
                         /* If the argument is of the form @X then substituted the token number of X, not the value of X */
                         if (cp > 0 && z[cp - 1] == '@')
                         {
                             b.Length--;
                             b.AppendFormat("yymsp[{0}].major", i - rule.RHSymbols.Length + 1);
                         }
                         else
                         {
                             var symbol = rule.RHSymbols[i];
                             var dataTypeID = (symbol.Type == SymbolType.MultiTerminal ? symbol.Children[0].DataTypeID : symbol.DataTypeID);
                             b.AppendFormat("yymsp[{0}].minor.yy{1}", i - rule.RHSymbols.Length + 1, dataTypeID);
                         }
                         cp = xp;
                         used[i] = true;
                         break;
                     }
             }
         }
         b.Append(z[cp]);
     }
     /* Check to make sure the LHS has been used */
     if (rule.LHSymbolAlias != null && !lhsused)
         ctx.RaiseError(ref ctx.Errors, rule.RuleLineno, "Label \"{0}\" for \"{1}({2})\" is never used.", rule.LHSymbolAlias, rule.LHSymbol.Name, rule.LHSymbolAlias);
     /* Generate destructor code for RHS symbols which are not used in the reduce code */
     for (var i = 0; i < rule.RHSymbols.Length; i++)
     {
         if (rule.RHSymbolsAlias[i] != null && !used[i])
             ctx.RaiseError(ref ctx.Errors, rule.RuleLineno, "Label {0} for \"{1}({2})\" is never used.", rule.RHSymbolsAlias[i], rule.RHSymbols[i].Name, rule.RHSymbolsAlias[i]);
         else if (rule.RHSymbolsAlias[i] == null && HasDestructor(rule.RHSymbols[i], ctx))
             b.AppendFormat("  yy_destructor(yypParser,{0},&yymsp[{1}].minor);\n", rule.RHSymbols[i].ID, i - rule.RHSymbols.Length + 1);
     }
     if (rule.Code != null)
         rule.Code = (b.ToString() ?? string.Empty);
 }
开发者ID:BclEx,项目名称:AdamsyncEx,代码行数:61,代码来源:EmitterC.cs


示例20: AddNewRule

 public override Rule AddNewRule(string name, string pageTypeLeft, string pageTypeRight, string ruleTextLeft, string ruleTextRight)
 {
     if (!RuleExists(name))
     {
         RuleEventArgs e = new RuleEventArgs();
         e.RuleName = name;
         e.CurrentRule = null;
         if (OnCreatingRule != null)
             OnCreatingRule(null, e);
         if (!e.CancelEvent)
         {
             Rule newRule = new Rule(name, pageTypeLeft, pageTypeRight);
             newRule.RuleTextLeft = ruleTextLeft;
             newRule.RuleTextRight = ruleTextRight;
             RuleDataStore.Save(newRule);
             e.CurrentRule = newRule;
             if (OnCreatedRule != null)
                 OnCreatedRule(null, e);
             UpdateCache();
             return newRule;
         }
         else
             return null;
     }
     return null;
 }
开发者ID:BVNetwork,项目名称:Relations,代码行数:26,代码来源:DDSInMemoryRuleProvider.cs



注:本文中的Rule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RuleContext类代码示例发布时间:2022-05-24
下一篇:
C# RubyRegexOptions类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap