WF4.0 Beta1之旅(5):规则引擎的变化
2010-10-01 08:33:17 来源:WEB开发网效果如下图:
下面是当点击按钮后,会出现RuleSet的编辑器:
using System;
using System.Activities;
using System.Windows;
using System.Windows.Forms;
using System.Workflow.Activities.Rules;
using System.Workflow.Activities.Rules.Design;
namespace Microsoft.Samples.Rules
{
// Interaction logic for PolicyDesigner.xaml
public partial class PolicyDesigner
{
public PolicyDesigner()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
// verifiy that TargetObject property has been configured
object targetObject = ModelItem.Properties["TargetObject"].ComputedValue;
if (targetObject == null)
{
System.Windows.MessageBox.Show("TargetObject needs to be configured before adding the rules");
return;
}
// verify that target object is correctly configured
InOutArgument arg = targetObject as InOutArgument;
if (arg == null)
{
System.Windows.MessageBox.Show("Invalid target object");
return;
}
// open the ruleset editor
Type targetObjectType = arg.ArgumentType;
RuleSet ruleSet = ModelItem.Properties["RuleSet"].ComputedValue as RuleSet;
if (ruleSet == null)
ruleSet = new RuleSet();
RuleSetDialog ruleSetDialog = new RuleSetDialog(targetObjectType, null, ruleSet);
DialogResult result = ruleSetDialog.ShowDialog();
// update the model item
if (result == DialogResult.OK)
{
ModelItem.Properties["RuleSet"].SetValue(ruleSetDialog.RuleSet);
}
}
}
}
这样我们就可以再WF4.0中使用该活动了,如下图:
系列文章:
WF4.0 Beta1之旅(1):基本介绍
WF4.0 Beta1之旅(2):异常处理
WF4.0 Beta1之旅(3):全新的FlowChart
WF4.0 Beta1之旅(4):Bookmark的使用
- ››WF 4.0 beta1中的跟踪机制
- ››WF 4.0的建模风格:顺序和Flowchart
- ››WF4.0 Beta1之旅(5):规则引擎的变化
- ››WF 4.0 beta1活动概览(1):Procedural
- ››WF4.0 Beta1之旅(4):Bookmark的使用
- ››WF4.0 Beta1之旅:基本介绍
- ››WF4.0 Beta1之旅(2):异常处理
- ››WF4.0 Beta1之旅(3):全新的FlowChart
- ››WF 应用场景指南: SharePoint 与工作流(上)
- ››WF 应用场景指南: 展现流(Presentation Flow)
- ››WF单元测试系列1:测试基本的Activity
- ››WF单元测试系列2:简单测试Activity的行为
更多精彩
赞助商链接