• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ValidationErrorCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: FillCorrelationAliasAttrs

 private static void FillCorrelationAliasAttrs(MemberInfo memberInfo, Hashtable correlationAliasAttrs, ValidationErrorCollection validationErrors)
 {
     foreach (object obj2 in memberInfo.GetCustomAttributes(typeof(CorrelationAliasAttribute), false))
     {
         CorrelationAliasAttribute attributeFromObject = Helpers.GetAttributeFromObject<CorrelationAliasAttribute>(obj2);
         if (string.IsNullOrEmpty(attributeFromObject.Name) || (attributeFromObject.Name.Trim().Length == 0))
         {
             ValidationError item = new ValidationError(SR.GetString(CultureInfo.CurrentCulture, "Error_CorrelationAttributeInvalid", new object[] { typeof(CorrelationAliasAttribute).Name, "Name", memberInfo.Name }), 0x150);
             item.UserData.Add(typeof(CorrelationAliasAttribute), memberInfo.Name);
             validationErrors.Add(item);
         }
         else if (string.IsNullOrEmpty(attributeFromObject.Path) || (attributeFromObject.Path.Trim().Length == 0))
         {
             ValidationError error2 = new ValidationError(SR.GetString(CultureInfo.CurrentCulture, "Error_CorrelationAttributeInvalid", new object[] { typeof(CorrelationAliasAttribute).Name, "Path", memberInfo.Name }), 0x150);
             error2.UserData.Add(typeof(CorrelationAliasAttribute), memberInfo.Name);
             validationErrors.Add(error2);
         }
         else if (correlationAliasAttrs.Contains(attributeFromObject.Name))
         {
             ValidationError error3 = new ValidationError(SR.GetString(CultureInfo.CurrentCulture, "Error_DuplicateCorrelationAttribute", new object[] { typeof(CorrelationAliasAttribute).Name, attributeFromObject.Name, memberInfo.Name }), 0x151);
             error3.UserData.Add(typeof(CorrelationAliasAttribute), memberInfo.Name);
             validationErrors.Add(error3);
         }
         else
         {
             correlationAliasAttrs.Add(attributeFromObject.Name, attributeFromObject);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:CorrelationSetsValidator.cs


示例2: RuleValidation

 public RuleValidation(Activity activity, ITypeProvider typeProvider, bool checkStaticType)
 {
     this.errors = new ValidationErrorCollection();
     this.typesUsed = new Dictionary<string, Type>(0x10);
     this.activeParentNodes = new Stack<CodeExpression>();
     this.expressionInfoMap = new Dictionary<CodeExpression, RuleExpressionInfo>();
     this.typeRefMap = new Dictionary<CodeTypeReference, Type>();
     if (activity == null)
     {
         throw new ArgumentNullException("activity");
     }
     if (typeProvider == null)
     {
         throw new ArgumentNullException("typeProvider");
     }
     this.thisType = ConditionHelper.GetContextType(typeProvider, activity);
     this.typeProvider = typeProvider;
     this.checkStaticType = checkStaticType;
     if (checkStaticType)
     {
         this.authorizedTypes = WorkflowCompilationContext.Current.GetAuthorizedTypes();
         this.typesUsedAuthorized = new Dictionary<string, Type>();
         this.typesUsedAuthorized.Add(voidTypeName, voidType);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:RuleValidation.cs


示例3: SetErrors

        /// <summary>
        /// Inherited from <see cref="IValidationManager"/>.
        /// <para>
        /// This manager assumes all objects within <paramref name="validationResult"/> are of type <see cref="ValidationResult"/>.
        /// </para>
        /// <para>
        /// This manager assumes all <see cref="ValidationResult"/> objects within <paramref name="validationResult"/> that 
        /// have an empty <see cref="P:ValidationResult.MemberNames"/> collection are top level or class level issues.
        /// </para>
        /// </summary>
        /// <param name="errorCollection">A <see cref="ValidationErrorCollection"/> that houses the validation results.</param>
        /// <param name="validationResult">A <see cref="IEnumerable{T}"/> that represents the collection of validation issues that need to be applied to <paramref name="errorCollection"/>.</param>
        public virtual void SetErrors(ValidationErrorCollection errorCollection, IEnumerable<object> validationResult)
        {
            lock (_syncObject)
            {
                IEnumerable<ValidationResult> vResults = validationResult.Cast<ValidationResult>();

                var results =
                    (from g in
                         (from tuple in
                              (from r in vResults
                               from name in r.MemberNames
                               select new Tuple<string, ValidationResult>(name, r))
                          group tuple by tuple.Item1)
                     select new Tuple<string, IEnumerable<ValidationResult>>(g.Key, g.Select(a => a.Item2))).ToArray();

                if (vResults.Any(a => a.MemberNames.Count() == 0))
                {
                    Tuple<string, IEnumerable<ValidationResult>> newTuple = new Tuple<string, IEnumerable<ValidationResult>>(string.Empty, from vr in vResults
                                                                                                                                           where vr.MemberNames.Count() == 0
                                                                                                                                           select vr);
                    results = results.Concat(new Tuple<string, IEnumerable<ValidationResult>>[] { newTuple }).ToArray();
                }

                errorCollection.Clear();

                foreach (Tuple<string, IEnumerable<ValidationResult>> item in results)
                    errorCollection.SetErrors(item.Item1, item.Item2.Cast<object>());
            }
        }
开发者ID:KCL5South,项目名称:PTPDevelopmentLibrary,代码行数:41,代码来源:DataAnnotationsValidationManager.cs


示例4: ValidateCustomStateActivity

 private static void ValidateCustomStateActivity(StateActivity state, ValidationErrorCollection validationErrors)
 {
     if (state.Activities.Count > 0)
     {
         validationErrors.Add(new ValidationError(SR.GetError_BlackBoxCustomStateNotSupported(), ErrorNumbers.Error_BlackBoxCustomStateNotSupported));
     }
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:7,代码来源:StateValidator.cs


示例5: MinLengthViolationTest

 public void MinLengthViolationTest()
 {
     MinimumLengthAttribute attribute = new MinimumLengthAttribute(8);
     ValidationErrorCollection errors = new ValidationErrorCollection();
     attribute.Validate(minLengthNode, valueInfo1, errors);
     Assert.AreEqual(1, errors.Count);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:7,代码来源:MinimumLengthAttributeFixture.cs


示例6: 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


示例7: RequiredNotThereTest

 public void RequiredNotThereTest()
 {
     RequiredAttribute attribute = new RequiredAttribute();
     ValidationErrorCollection errors = new ValidationErrorCollection();
     attribute.Validate(requiredNode, valueInfo1, errors);
     Assert.AreEqual(1, errors.Count);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:7,代码来源:RequiredAttributeFixture.cs


示例8: SetValidationErrors

 internal void SetValidationErrors(ValidationErrorCollection errors)
 {
     foreach(ValidationError error in errors)
         {
             validationErrorsBox.Items.Add(error);
         }
 }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:7,代码来源:ValidationErrors.cs


示例9: 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


示例10: MaxLengthViolationTest

 public void MaxLengthViolationTest()
 {
     MaximumLengthAttribute attribute = new MaximumLengthAttribute(3);
     maxLengthNode.Value1 = "aaaa";
     ValidationErrorCollection errors = new ValidationErrorCollection();
     attribute.Validate(maxLengthNode, valueInfo1, errors);
     Assert.AreEqual(1, errors.Count);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:8,代码来源:MaximumLengthAttributeFixture.cs


示例11: CharOutOfRangeTest

 public void CharOutOfRangeTest()
 {
     AssertRangeAttribute assertRange = new AssertRangeAttribute('a', RangeBoundaryType.Inclusive, 'd', RangeBoundaryType.Exclusive);
     rangeClass.CharValue = 'd';
     ValidationErrorCollection errors = new ValidationErrorCollection();
     assertRange.Validate(rangeClass, charInfo, errors);
     Assert.AreEqual(1, errors.Count);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:8,代码来源:AssertRangeAttributeFixture.cs


示例12: MinLengthTest

 public void MinLengthTest()
 {
     MinimumLengthAttribute attribute = new MinimumLengthAttribute(8);
     minLengthNode.Value2 = "MyTestPassword";
     ValidationErrorCollection errors = new ValidationErrorCollection();
     attribute.Validate(minLengthNode, valueInfo2, errors);
     Assert.AreEqual(0, errors.Count);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:8,代码来源:MinimumLengthAttributeFixture.cs


示例13: ValidTypeProducesNoErrors

 public void ValidTypeProducesNoErrors()
 {
     TypeValidationAttribute attribute = new TypeValidationAttribute();
     ValidationErrorCollection errors = new ValidationErrorCollection();
     typeNode.TypeName = GetType().AssemblyQualifiedName;
     attribute.Validate(typeNode, valueInfo1, errors);
     Assert.AreEqual(0, errors.Count);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:8,代码来源:TypeValidationAttributeFixture.cs


示例14: InvalidTypeProducesAnError

 public void InvalidTypeProducesAnError()
 {
     TypeValidationAttribute attribute = new TypeValidationAttribute();
     typeNode.TypeName = "MyTest";
     ValidationErrorCollection errors = new ValidationErrorCollection();
     attribute.Validate(typeNode, valueInfo1, errors);
     Assert.AreEqual(1, errors.Count);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:8,代码来源:TypeValidationAttributeFixture.cs


示例15: FloatInRangeTest

 public void FloatInRangeTest()
 {
     AssertRangeAttribute assertRange = new AssertRangeAttribute(3f, RangeBoundaryType.Inclusive, 43f, RangeBoundaryType.Exclusive);
     rangeClass.FloatValue = 25;
     ValidationErrorCollection errors = new ValidationErrorCollection();
     assertRange.Validate(rangeClass, floatInfo, errors);
     Assert.AreEqual(0, errors.Count);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:8,代码来源:AssertRangeAttributeFixture.cs


示例16: DoubleOutOfRangeTest

 public void DoubleOutOfRangeTest()
 {
     AssertRangeAttribute assertRange = new AssertRangeAttribute(3D, RangeBoundaryType.Inclusive, 43D, RangeBoundaryType.Exclusive);
     rangeClass.DoubleValue = 2;
     ValidationErrorCollection errors = new ValidationErrorCollection();
     assertRange.Validate(rangeClass, doubleInfo, errors);
     Assert.AreEqual(1, errors.Count);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:8,代码来源:AssertRangeAttributeFixture.cs


示例17: RequiredValueTest

 public void RequiredValueTest()
 {
     RequiredAttribute attribute = new RequiredAttribute();
     requiredNode.Value2 = "MyTest";
     ValidationErrorCollection errors = new ValidationErrorCollection();
     attribute.Validate(requiredNode, valueInfo2, errors);
     Assert.AreEqual(0, ValidationErrorsCount);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:8,代码来源:RequiredAttributeFixture.cs


示例18: RegexViolationTest

 public void RegexViolationTest()
 {
     RegexAttribute attribute = new RegexAttribute(@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
     regexNode.Email = "joeblow";
     ValidationErrorCollection errors = new ValidationErrorCollection();
     attribute.Validate(regexNode, emailInfo, errors);
     Assert.AreEqual(1, errors.Count);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:8,代码来源:RegexAttributeFixture.cs


示例19: RuleSetValidationException

 protected RuleSetValidationException(SerializationInfo serializeInfo, StreamingContext context) : base(serializeInfo, context)
 {
     if (serializeInfo == null)
     {
         throw new ArgumentNullException("serializeInfo");
     }
     this.m_errors = (ValidationErrorCollection) serializeInfo.GetValue("errors", typeof(ValidationErrorCollection));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:RuleSetValidationException.cs


示例20: WorkflowValidationFailedException

 public WorkflowValidationFailedException(string message, ValidationErrorCollection errors) : base(message)
 {
     if (errors == null)
     {
         throw new ArgumentNullException("errors");
     }
     this.errors = XomlCompilerHelper.MorphIntoFriendlyValidationErrors(errors);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:WorkflowValidationFailedException.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ValidationErrorHandler类代码示例发布时间:2022-05-24
下一篇:
C# ValidationContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap