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


C# Compiler.ValidationManager类代码示例

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


ValidationManager类属于System.Workflow.ComponentModel.Compiler命名空间,在下文中一共展示了ValidationManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Validate

        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            if (manager == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("manager");
            }

            ValidationErrorCollection validationErrors = ValidationHelpers.ValidateObject(manager, obj);
            if (validationErrors.Count == 0)
            {
                if (manager.Context == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                        new InvalidOperationException(SR2.GetString(SR2.Error_ContextStackMissing)));
                }

                Activity rootActivity = manager.Context[typeof(Activity)] as Activity;
                if (rootActivity == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                        new InvalidOperationException(SR2.GetString(SR2.Error_ContextStackItemMissing, typeof(Activity).Name)));
                }
                else
                {
                    validationErrors.AddRange(ValidationHelper.ValidateAllServiceOperationsImplemented(manager, rootActivity));
                }
            }

            return validationErrors;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:30,代码来源:WorkflowServiceAttributesDynamicPropertyValidator.cs

示例2: GetFullPropertyName

        protected string GetFullPropertyName(ValidationManager manager)
        {
            if (manager == null)
                throw new ArgumentNullException("manager");

            string fullName = string.Empty;

            // iterate the properties in the stack starting with the last one
            int iterator = 0;
            while (manager.Context[iterator] != null)
            {
                if (manager.Context[iterator] is PropertyValidationContext)
                {
                    PropertyValidationContext propertyValidationContext = manager.Context[iterator] as PropertyValidationContext;
                    if (propertyValidationContext.PropertyName == string.Empty)
                        fullName = string.Empty;  // property chain broke... dicard properties after break
                    else if (fullName == string.Empty)
                        fullName = propertyValidationContext.PropertyName;
                    else
                        fullName = propertyValidationContext.PropertyName + "." + fullName;
                }
                iterator++;
            }

            return fullName;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:26,代码来源:Validator.cs

示例3: Validate

 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = base.Validate(manager, obj);
     StateFinalizationActivity compositeActivity = obj as StateFinalizationActivity;
     if (compositeActivity == null)
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(StateFinalizationActivity).FullName }), "obj");
     }
     StateActivity parent = compositeActivity.Parent as StateActivity;
     if (parent == null)
     {
         errors.Add(new ValidationError(SR.GetError_StateFinalizationParentNotState(), 0x606));
         return errors;
     }
     foreach (Activity activity3 in parent.EnabledActivities)
     {
         StateFinalizationActivity activity4 = activity3 as StateFinalizationActivity;
         if ((activity4 != null) && (activity4 != compositeActivity))
         {
             errors.Add(new ValidationError(SR.GetError_MultipleStateFinalizationActivities(), 0x61a));
             break;
         }
     }
     if (StateMachineHelpers.ContainsEventActivity(compositeActivity))
     {
         errors.Add(new ValidationError(SR.GetError_EventActivityNotValidInStateFinalization(), 0x603));
     }
     return errors;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:StateFinalizationValidator.cs

示例4: Validate

 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = base.Validate(manager, obj);
     ParallelActivity activity = obj as ParallelActivity;
     if (activity == null)
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(ParallelActivity).FullName }), "obj");
     }
     if (activity.EnabledActivities.Count < 2)
     {
         errors.Add(new ValidationError(SR.GetString("Error_ParallelLessThanTwoChildren"), 0x517));
     }
     bool flag = false;
     foreach (Activity activity2 in activity.EnabledActivities)
     {
         if (activity2.GetType() != typeof(SequenceActivity))
         {
             flag = true;
         }
     }
     if (flag)
     {
         errors.Add(new ValidationError(SR.GetString("Error_ParallelNotAllSequence"), 0x518));
     }
     return errors;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:ParallelValidator.cs

示例5: Validate

        public override ValidationErrorCollection Validate(
            ValidationManager manager,
            object obj)
        {
            ValidationErrorCollection validationErrors = base.Validate(manager, obj);

            SendActivity sendActivity = obj as SendActivity;
            if (sendActivity == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("obj",
                    SR2.GetString(SR2.Error_ArgumentTypeInvalid, "obj", typeof(SendActivity)));
            }

            ITypeProvider typeProvider = manager.GetService(typeof(ITypeProvider)) as ITypeProvider;
            if (typeProvider == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                    SR2.GetString(SR2.General_MissingService, typeof(ITypeProvider).Name)));
            }

            if (sendActivity.ServiceOperationInfo == null)
            {
                validationErrors.Add(
                    new ValidationError(
                    SR2.GetString(SR2.Error_ServiceOperationInfoNotSpecified,
                    sendActivity.Name),
                    WorkflowServicesErrorNumbers.Error_OperationInfoNotSpecified,
                    false,
                    "ServiceOperationInfo"));
            }
            else
            {
                // validate operation info
                //
                ValidationErrorCollection operationInfoValidationErrors =
                    ValidationHelper.ValidateOperationInfo(
                    sendActivity,
                    sendActivity.ServiceOperationInfo,
                    manager);

                validationErrors.AddRange(operationInfoValidationErrors);

                // do not validate parameter binding if the operation info is not valid
                // we might generate noise and false positives.
                //
                if (operationInfoValidationErrors.Count == 0)
                {
                    validationErrors.AddRange(
                        ValidationHelper.ValidateParameterBindings(sendActivity, sendActivity.ServiceOperationInfo,
                        sendActivity.ParameterBindings, manager));
                }

                // validate the endpoint
                //
                validationErrors.AddRange(
                    ValidationHelper.ValidateChannelToken(sendActivity, manager));
            }

            return validationErrors;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:60,代码来源:SendActivityValidator.cs

示例6: ValidateProperties

 public virtual ValidationErrorCollection ValidateProperties(ValidationManager manager, object obj)
 {
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
     if (obj == null)
     {
         throw new ArgumentNullException("obj");
     }
     ValidationErrorCollection errors = new ValidationErrorCollection();
     Activity activity = manager.Context[typeof(Activity)] as Activity;
     Walker walker = new Walker(true);
     walker.FoundProperty += delegate (Walker w, WalkerEventArgs args) {
         if ((args.CurrentProperty != null) && (DependencyProperty.FromName(args.CurrentProperty.Name, args.CurrentProperty.DeclaringType) == null))
         {
             object[] customAttributes = args.CurrentProperty.GetCustomAttributes(typeof(ValidationOptionAttribute), true);
             if (((customAttributes.Length > 0) ? ((ValidationOptionAttribute) customAttributes[0]).ValidationOption : ValidationOption.Optional) != ValidationOption.None)
             {
                 errors.AddRange(this.ValidateProperty(args.CurrentProperty, args.CurrentPropertyOwner, args.CurrentValue, manager));
                 args.Action = WalkerAction.Skip;
             }
         }
     };
     walker.WalkProperties(activity, obj);
     return errors;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:Validator.cs

示例7: GetFullPropertyName

 protected string GetFullPropertyName(ValidationManager manager)
 {
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
     string propertyName = string.Empty;
     for (int i = 0; manager.Context[i] != null; i++)
     {
         if (manager.Context[i] is PropertyValidationContext)
         {
             PropertyValidationContext context = manager.Context[i] as PropertyValidationContext;
             if (context.PropertyName == string.Empty)
             {
                 propertyName = string.Empty;
             }
             else if (propertyName == string.Empty)
             {
                 propertyName = context.PropertyName;
             }
             else
             {
                 propertyName = context.PropertyName + "." + propertyName;
             }
         }
     }
     return propertyName;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:Validator.cs

示例8: Validate

 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = base.Validate(manager, obj);
     EventDrivenActivity activity = obj as EventDrivenActivity;
     if (activity == null)
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(EventDrivenActivity).FullName }), "obj");
     }
     if ((!(activity.Parent is ListenActivity) && !(activity.Parent is EventHandlersActivity)) && !(activity.Parent is StateActivity))
     {
         errors.Add(new ValidationError(SR.GetError_EventDrivenParentNotListen(), 0x510));
     }
     string errorText = string.Empty;
     int errorNumber = -1;
     Activity activity2 = (activity.EnabledActivities.Count > 0) ? activity.EnabledActivities[0] : null;
     if (activity2 == null)
     {
         errorText = SR.GetString("Error_EventDrivenNoFirstActivity");
         errorNumber = 0x511;
     }
     else if (!(activity2 is IEventActivity))
     {
         errorText = SR.GetError_EventDrivenInvalidFirstActivity();
         errorNumber = 0x512;
     }
     if (errorText.Length > 0)
     {
         errors.Add(new ValidationError(errorText, errorNumber));
     }
     return errors;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:EventDrivenValidator.cs

示例9: Validate

        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            ValidationErrorCollection validationErrors = base.Validate(manager, obj);

            EventDrivenActivity eventDriven = obj as EventDrivenActivity;
            if (eventDriven == null)
                throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(EventDrivenActivity).FullName), "obj");

            // check parent 
            if (!(eventDriven.Parent is ListenActivity) &&
                !(eventDriven.Parent is EventHandlersActivity) &&
                !(eventDriven.Parent is StateActivity)
                )
                validationErrors.Add(new ValidationError(SR.GetError_EventDrivenParentNotListen(), ErrorNumbers.Error_EventDrivenParentNotListen));

            // validate Event property
            string message = string.Empty;
            int errorNumber = -1;
            Activity firstActivity = (eventDriven.EnabledActivities.Count > 0) ? eventDriven.EnabledActivities[0] : null;
            if (firstActivity == null)
            {
                message = SR.GetString(SR.Error_EventDrivenNoFirstActivity);
                errorNumber = ErrorNumbers.Error_EventDrivenNoFirstActivity;
            }
            else if (!(firstActivity is IEventActivity))
            {
                message = SR.GetError_EventDrivenInvalidFirstActivity();
                errorNumber = ErrorNumbers.Error_EventDrivenInvalidFirstActivity;
            }
            if (message.Length > 0)
                validationErrors.Add(new ValidationError(message, errorNumber));

            return validationErrors;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:34,代码来源:EventDriven.cs

示例10: Validate

 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = new ValidationErrorCollection(base.Validate(manager, obj));
     ListenActivity activity = obj as ListenActivity;
     if (activity == null)
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(ListenActivity).FullName }), "obj");
     }
     if (activity.EnabledActivities.Count < 2)
     {
         errors.Add(new ValidationError(SR.GetString("Error_ListenLessThanTwoChildren"), 0x513));
     }
     bool flag = false;
     foreach (Activity activity2 in activity.EnabledActivities)
     {
         if (!(activity2 is EventDrivenActivity))
         {
             flag = true;
         }
     }
     if (flag)
     {
         errors.Add(new ValidationError(SR.GetString("Error_ListenNotAllEventDriven"), 0x514));
     }
     return errors;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:ListenValidator.cs

示例11: Validate

 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = base.Validate(manager, obj);
     EventHandlersActivity activity = obj as EventHandlersActivity;
     if (activity == null)
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(EventHandlersActivity).FullName }), "obj");
     }
     if (activity.Parent == null)
     {
         errors.Add(new ValidationError(SR.GetString("Error_MustHaveParent"), 0x522));
         return errors;
     }
     if (!(activity.Parent is EventHandlingScopeActivity))
     {
         errors.Add(new ValidationError(SR.GetString("Error_EventHandlersDeclParentNotScope", new object[] { activity.Parent.QualifiedName }), 0x522));
     }
     bool flag = false;
     foreach (Activity activity2 in activity.EnabledActivities)
     {
         if (!(activity2 is EventDrivenActivity))
         {
             flag = true;
         }
     }
     if (flag)
     {
         errors.Add(new ValidationError(SR.GetString("Error_ListenNotAllEventDriven"), 0x514));
     }
     return errors;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:EventHandlersValidator.cs

示例12: Validate

 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = base.Validate(manager, obj);
     if (!(obj is ConditionedActivityGroup))
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(ConditionedActivityGroup).FullName }), "obj");
     }
     return errors;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:ConditionedActivityGroupValidator.cs

示例13: Validate

        public virtual ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            if (manager == null)
                throw new ArgumentNullException("manager");
            if (obj == null)
                throw new ArgumentNullException("obj");

            return new ValidationErrorCollection();
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:9,代码来源:Validator.cs

示例14: Validate

 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = base.Validate(manager, obj);
     if (!(obj is ActivityCondition))
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(ActivityCondition).FullName }), "obj");
     }
     errors.AddRange(this.ValidateProperties(manager, obj));
     return errors;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:ConditionValidator.cs

示例15: Validate

 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     if (!(obj is CallExternalMethodActivity))
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(CallExternalMethodActivity).FullName }), "obj");
     }
     ValidationErrorCollection errors = base.Validate(manager, obj);
     errors.AddRange(CorrelationSetsValidator.Validate(manager, obj));
     errors.AddRange(ParameterBindingValidator.Validate(manager, obj));
     return errors;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:CallExternalMethodActivityValidator.cs


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