惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
Vercel News
Vercel News
月光博客
月光博客
S
SegmentFault 最新的问题
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
U
Unit 42
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
B
Blog RSS Feed
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
小众软件
小众软件
WordPress大学
WordPress大学
G
Google Developers Blog
Recent Announcements
Recent Announcements
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
F
Fortinet All Blogs
博客园 - 【当耐特】
I
InfoQ

博客园 - gotolovo

导出csv 导出excel 正则学习电话匹配 logmanager des 加密 解密 - gotolovo c# 发送邮件 工作流学习过程-事务 工作流学习过程-状态机 蛋疼的viewstate 工作流学习过程-持久化服务 工作流学习过程-使用关联 工作流学习过程-本地服务之事件处理 工作流学习过程-本地服务之调用方法 工作流学习过程-自定义活动 工作流学习过程-开篇 基本的几个排序算法 关于sql中时间的格式转换 数据行变列 请编程遍历页面上所有TextBox控件并给它赋值为空
工作流学习过程-验证活动
gotolovo · 2010-10-25 · via 博客园 - gotolovo

继上一篇 我们清楚 当我们拖放一个系统活动到工作流中的时候 系统会给我我们提示某某属性未赋值活未实行什么事件之类的
那么我们自定义活动来如何实现和系统一样的验证过程呢
定义一个继承于ActivityValidator的类。并重写Validator方法 
 和系统活动一样哦。会给予相关的错误提示 

代码

public class AccountValidator:ActivityValidator
{
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
{
ValidationErrorCollection errors
= base.Validate(manager,obj);

AccountActivity activity

= obj as AccountActivity;
if (activity.Parent != null)
{
if( String.IsNullOrEmpty(activity.AccountName)||activity.AccountName.Length<4)
{
errors.Add(ValidationError.GetNotSetValidationError(
"AccountName"));
}
}
return errors;
}
}

修改AccountActivity为

[ActivityValidator(typeof(AccountValidator))]
public sealed partial class AccountActivity: Activity

这样就完成了 自定义活动的验证过程