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


C# ValidationManager.GetValidators方法代码示例

本文整理汇总了C#中System.Workflow.ComponentModel.Compiler.ValidationManager.GetValidators方法的典型用法代码示例。如果您正苦于以下问题:C# ValidationManager.GetValidators方法的具体用法?C# ValidationManager.GetValidators怎么用?C# ValidationManager.GetValidators使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Workflow.ComponentModel.Compiler.ValidationManager的用法示例。


在下文中一共展示了ValidationManager.GetValidators方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidateObject

 internal static ValidationErrorCollection ValidateObject(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = new ValidationErrorCollection();
     if (obj != null)
     {
         Type type = obj.GetType();
         if (type.IsPrimitive || !(type != typeof(string)))
         {
             return errors;
         }
         bool flag = false;
         Dictionary<int, object> context = manager.Context[typeof(Dictionary<int, object>)] as Dictionary<int, object>;
         if (context == null)
         {
             context = new Dictionary<int, object>();
             manager.Context.Push(context);
             flag = true;
         }
         try
         {
             if (context.ContainsKey(obj.GetHashCode()))
             {
                 return errors;
             }
             context.Add(obj.GetHashCode(), obj);
             try
             {
                 foreach (Validator validator in manager.GetValidators(type))
                 {
                     errors.AddRange(validator.Validate(manager, obj));
                 }
             }
             finally
             {
                 context.Remove(obj.GetHashCode());
             }
         }
         finally
         {
             if (flag)
             {
                 manager.Context.Pop();
             }
         }
     }
     return errors;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:47,代码来源:ValidationHelpers.cs

示例2: ValidateDefinition

        void ValidateDefinition()
        {
            ValidationErrorCollection errors = new ValidationErrorCollection();
            Activity rootActivity = GetWorkflowDefinition();

            ITypeProvider typeProvider = CreateTypeProvider(rootActivity);

            ServiceContainer serviceContainer = new ServiceContainer();
            serviceContainer.AddService(typeof(ITypeProvider), typeProvider);

            ValidationManager validationManager = new ValidationManager(serviceContainer);
            foreach (Validator validator in validationManager.GetValidators(rootActivity.GetType()))
            {
                foreach (ValidationError error in validator.Validate(validationManager, rootActivity))
                {
                    if (!error.UserData.Contains(typeof(Activity)))
                    {
                        error.UserData[typeof(Activity)] = rootActivity;
                    }

                    errors.Add(error);
                }
            }

            OnValidate(errors);

            if (errors.HasErrors)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WorkflowValidationFailedException(SR2.WorkflowValidationFailed, errors));
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:31,代码来源:WorkflowDefinitionContext.cs

示例3: ValidateObject

        internal static ValidationErrorCollection ValidateObject(ValidationManager manager, object obj)
        {
            ValidationErrorCollection errors = new ValidationErrorCollection();
            if (obj == null)
                return errors;

            Type objType = obj.GetType();
            if (!objType.IsPrimitive && (objType != typeof(string)))
            {
                bool removeValidatedObjectCollection = false;
                Dictionary<int, object> validatedObjects = manager.Context[typeof(Dictionary<int, object>)] as Dictionary<int, object>;
                if (validatedObjects == null)
                {
                    validatedObjects = new Dictionary<int, object>();
                    manager.Context.Push(validatedObjects);
                    removeValidatedObjectCollection = true;
                }

                try
                {
                    if (!validatedObjects.ContainsKey(obj.GetHashCode()))
                    {
                        validatedObjects.Add(obj.GetHashCode(), obj);
                        try
                        {
                            Validator[] validators = manager.GetValidators(objType);
                            foreach (Validator validator in validators)
                                errors.AddRange(validator.Validate(manager, obj));
                        }
                        finally
                        {
                            validatedObjects.Remove(obj.GetHashCode());
                        }
                    }
                }
                finally
                {
                    if (removeValidatedObjectCollection)
                        manager.Context.Pop();
                }
            }

            return errors;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:44,代码来源:ValidationHelpers.cs

示例4: ValidateActivity

 internal static void ValidateActivity(Activity activity, WorkflowCompilerParameters parameters, WorkflowCompilerResults results)
 {
     ValidationManager manager = new ValidationManager(WorkflowCompilationContext.Current.ServiceProvider);
     foreach (Validator validator in manager.GetValidators(activity.GetType()))
     {
         try
         {
             foreach (ValidationError error in validator.Validate(manager, activity))
             {
                 if (!error.UserData.Contains(typeof(Activity)))
                 {
                     error.UserData[typeof(Activity)] = activity;
                 }
                 results.Errors.Add(CreateXomlCompilerError(error, parameters));
             }
         }
         catch (TargetInvocationException exception)
         {
             Exception exception2 = exception.InnerException ?? exception;
             ValidationError error2 = new ValidationError(SR.GetString("Error_ValidatorThrewException", new object[] { exception2.GetType().FullName, validator.GetType().FullName, activity.Name, exception2.ToString() }), 0x627);
             results.Errors.Add(CreateXomlCompilerError(error2, parameters));
         }
         catch (Exception exception3)
         {
             ValidationError error3 = new ValidationError(SR.GetString("Error_ValidatorThrewException", new object[] { exception3.GetType().FullName, validator.GetType().FullName, activity.Name, exception3.ToString() }), 0x627);
             results.Errors.Add(CreateXomlCompilerError(error3, parameters));
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:XomlCompilerHelper.cs

示例5: ValidateActivity

        internal static void ValidateActivity(Activity activity, WorkflowCompilerParameters parameters, WorkflowCompilerResults results)
        {
            ValidationErrorCollection errors = null;
            ValidationManager validationManager = new ValidationManager(WorkflowCompilationContext.Current.ServiceProvider);

            foreach (Validator validator in validationManager.GetValidators(activity.GetType()))
            {
                // Validate recursively.
                try
                {
                    errors = validator.Validate(validationManager, activity);
                    foreach (ValidationError error in errors)
                    {
                        if (!error.UserData.Contains(typeof(Activity)))
                            error.UserData[typeof(Activity)] = activity;
                        results.Errors.Add(CreateXomlCompilerError(error, parameters));
                    }
                }
                catch (TargetInvocationException tie)
                {
                    Exception e = tie.InnerException ?? tie;
                    ValidationError error = new ValidationError(SR.GetString(SR.Error_ValidatorThrewException, e.GetType().FullName, validator.GetType().FullName, activity.Name, e.ToString()), ErrorNumbers.Error_ValidatorThrewException);
                    results.Errors.Add(CreateXomlCompilerError(error, parameters));
                }
                catch (Exception e)
                {
                    ValidationError error = new ValidationError(SR.GetString(SR.Error_ValidatorThrewException, e.GetType().FullName, validator.GetType().FullName, activity.Name, e.ToString()), ErrorNumbers.Error_ValidatorThrewException);
                    results.Errors.Add(CreateXomlCompilerError(error, parameters));
                }
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:31,代码来源:XomlCompilerHelpers.cs


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