本文整理汇总了C#中System.Workflow.ComponentModel.Compiler.ActivityValidator类的典型用法代码示例。如果您正苦于以下问题:C# ActivityValidator类的具体用法?C# ActivityValidator怎么用?C# ActivityValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActivityValidator类属于System.Workflow.ComponentModel.Compiler命名空间,在下文中一共展示了ActivityValidator类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Validate
class ConsoleWriteLineActivityValidator : ActivityValidator
{
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
{
// Invoke the base class method implementation to
// perform default validation.
ValidationErrorCollection errors = base.Validate(manager, obj);
// Make sure there is an activity instance.
ConsoleWriteLineActivity crw = obj as ConsoleWriteLineActivity;
if (crw == null)
{
throw new InvalidOperationException();
}
// If the activity has no parent then this validation
// is occurring during the compilation of the activity
// and not during the hosting or creation of an
// activity instance.
if (crw.Parent == null)
{
// Can skip the rest of the validation because
// it deals with the hosting and the creation
// of the activity.
return errors;
}
// Msg is required. Add a validation error if there is no
// Msg specified or Msg is not bound to another property.
if (string.IsNullOrEmpty(crw.Msg) &&
crw.GetBinding(ConsoleWriteLineActivity.MsgProperty) == null)
{
errors.Add(new ValidationError("Msg is required", 100, false, "Msg"));
}
return errors;
}
}
开发者ID:.NET开发者,项目名称:System.Workflow.ComponentModel.Compiler,代码行数:38,代码来源:ActivityValidator
注:本文中的System.Workflow.ComponentModel.Compiler.ActivityValidator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论