2014-09-26 104 views
-1

下面是我写的代码。我需要修改这是RR如何修改RuleAction中的内容

可用的内容。例如:我需要进行修改,以

"rr.ThenAction = "this.MacroLoop.Current.Strategy.SubStrategy.Current.Block.AIN.HLOP = 1" 

if (!ruleSet.Validate(rv)) 
{ 
List<System.Workflow.Activities.Rules.Rule> rulesList = new List<System.Workflow.Activities.Rules.Rule>(); 
rulesList = ruleSet.Rules.ToList(); 
foreach (System.Workflow.Activities.Rules.Rule rr in rulesList) 
{ 
    // I need to modify the content in rr 



} 
} 

帮助深表感谢

if rr.ThenAction = "this.MacroLoop.Current.Strategy.SubStrategy.Current.Block.AIN.HLOP = 0" 

+0

你需要检查循环中的每个rr吗? – 2014-09-26 09:46:12

+0

每个rr都需要修改。但内容将改变 – 2014-09-26 09:49:14

回答

0

我不确定,但你在找什么样的东西;

rulesList = ruleSet.Rules.ToList(); 
for (int i = 0; i < rulesList.Count; i++) 
     { 
      rulesList[i] = "sddfs"; 
      if(rulesList[i].ThenAction == "this.MacroLoop.Current.Strategy.SubStrategy.Current.Block.AIN.HLOP = 0") 
       { 
         rulesList[i].ThenAction = "this.MacroLoop.Current.Strategy.SubStrategy.Current.Block.AIN.HLOP = 1"; 
       } 
     } 

希望它有帮助... !!! PS:如果您打算在foreach中更改rr的值,那么它将不起作用,因为foreach是一个只读迭代器,它动态迭代实现IEnumerable的类,但是您可以使用item.value进行更改。

+0

我收到错误“Operator'=='不能应用于'System.Workflow.Activities.Rules.RuleAction'类型的操作数'和'字符串'\t” – 2014-09-26 10:25:39

+0

在这种情况下,您必须创建temp RuleAction有你想要比较的价值,也有你想要分享的价值 – 2014-09-26 10:30:10