当前位置: 首页>>代码示例>>C#>>正文


C# Rule类代码示例

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


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


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