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


C# System.Validation类代码示例

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


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

示例1: GetErrorInfo

 public string GetErrorInfo(Validation.ValidationException exc)
 {
     StringBuilder text = new StringBuilder();
     if (exc.ErrorInfos.Count > 0)
     {
         foreach (ErrorInfo info in exc.ErrorInfos)
         {
             foreach (ErrorText error in info.Errors)
             {
                 if (text.Length > 0)
                     text.AppendLine();
                 string errorText = string.Format(RuntimeContext.Service.L10N.GetText(error.Text) + "。", error.Args);
                 foreach (var f in info.FieldName)
                 {
                     text.Append(RuntimeContext.Service.L10N.GetText(f));
                     text.Append(" ");
                 }
                 text.Append(errorText);
             }
         }
     }
     else
         text.Append(exc.Message);
     return text.ToString();
 }
开发者ID:eolandezhang,项目名称:Diagram,代码行数:25,代码来源:ExceptionHandler.cs

示例2: ActivateMonitors

 public virtual RestResponse ActivateMonitors(int[] monitorIds, string tag, OutputType? output = null, Validation? validation = null)
 {
     var parameters = new Dictionary<string, object>();
     AddIfNotNull(parameters, Params.monitorIds, string.Join(",", monitorIds));
     AddIfNotNull(parameters, Params.tag, tag);
     RestResponse resp = MakePostRequest(GetAction(MonitorAction.activateMonitors), parameters, output: output, validation: validation);
     return resp;
 }
开发者ID:flin-aa,项目名称:Windows-Monitoring-Scripts,代码行数:8,代码来源:BaseMonitor.cs

示例3: BlockBase

		public BlockBase(string key, Line[] lines, string[] tags, GroupInfo group, Logger log) : base(-1, key, lines)
		{
			Group = group;
			Log = log;
			Valid = Validation.NeverRan;

			if (tags != null && tags.Length > 0)
				this.tags = new HashSet<string>(tags);
		}
开发者ID:TeaseAI,项目名称:TeaseAI-CE,代码行数:9,代码来源:BlockBase.cs

示例4: CollectPropertyEditors

 protected override Dictionary<PropertyEditor, Validation.RuleType.RuleType> CollectPropertyEditors(IEnumerable<RuleSetValidationResultItem> result, Validation.RuleType.RuleType ruleType) {
     var propertyEditors = base.CollectPropertyEditors(result, ruleType);
     foreach (var keyValuePair in propertyEditors) {
         var baseEdit = keyValuePair.Key.Control as BaseEdit;
         if (baseEdit != null)
             baseEdit.ErrorIcon = CreateImageFromResources(keyValuePair.Value);
     }
     return propertyEditors;
 }
开发者ID:aries544,项目名称:eXpand,代码行数:9,代码来源:RuleTypeController.cs

示例5: ActivateContact

 /// <summary>
 /// This action is used for contact activating. 
 /// </summary>
 /// <param name="contactId">id of the contact to activate</param>
 /// <param name="output">Type of output - XML or JSON</param>
 /// <param name="validation">HMACSHA1 for checksum validation or token for authToken validation</param>
 public void ActivateContact(int contactId, OutputType? output = null,
                             Validation? validation = null)
 {
     var parameters = new Dictionary<string, object>();
     parameters.Add(Params.contactId, contactId);
     RestResponse response = MakePostRequest(ContactAction.contactActivate, parameters, output: output,
                                    validation: validation);
     Helper.CheckStatus(response, GetOutput(output));
 }
开发者ID:flin-aa,项目名称:Windows-Monitoring-Scripts,代码行数:15,代码来源:Contact.cs

示例6: Matches_GivenValidString_DontReturnErrors

        public void Matches_GivenValidString_DontReturnErrors(string pis)
        {
            var person = new Person() { Pis = pis };

            var errors = new Validation<Person>(person)
                .Matches(x => x.Pis, @"^\d+$", "Error {0}")
                .ToList();

            Assert.Equal(0, errors.Count);
        }
开发者ID:Secullum,项目名称:Secullum.Validation,代码行数:10,代码来源:MatchesTests.cs

示例7: IsTimespan_GivenValidField_DontReturnErrors

        public void IsTimespan_GivenValidField_DontReturnErrors(string timespan)
        {
            var person = new Person() { Hour = timespan };

            var errors = new Validation<Person>(person)
                .IsTimespan(x => x.Hour)
                .ToList();

            Assert.Equal(0, errors.Count);
        }
开发者ID:Secullum,项目名称:Secullum.Validation,代码行数:10,代码来源:IsTimespanTests.cs

示例8: IsRequired_GivenValidString_DontReturnErrors

        public void IsRequired_GivenValidString_DontReturnErrors()
        {
            var person = new Person() { Name = "Fernando" };

            var errors = new Validation<Person>(person)
                .IsRequired(x => x.Name)
                .ToList();

            Assert.Equal(0, errors.Count);
        }
开发者ID:Secullum,项目名称:Secullum.Validation,代码行数:10,代码来源:IsRequiredTests.cs

示例9: IsUnique_GivenSameNameAndSameId_DontReturnErrors

        public void IsUnique_GivenSameNameAndSameId_DontReturnErrors()
        {
            var person = new Person() { Id = 1, Name = "fernando" };

            var errors = new Validation<Person>(person, context)
                .IsUnique(x => x.Name)
                .ToList();

            Assert.Equal(0, errors.Count);
        }
开发者ID:Secullum,项目名称:Secullum.Validation,代码行数:10,代码来源:IsUniqueTests.cs

示例10: IsRequired_GivenValidInt_DontReturnErrors

        public void IsRequired_GivenValidInt_DontReturnErrors()
        {
            var person = new Person() { Age = 21 };

            var errors = new Validation<Person>(person)
                .IsRequired(x => x.Age)
                .ToList();

            Assert.Equal(0, errors.Count);
        }
开发者ID:Secullum,项目名称:Secullum.Validation,代码行数:10,代码来源:IsRequiredTests.cs

示例11: IsUnique_GivenNewAgeAndSameId_DontReturnErrors

        public void IsUnique_GivenNewAgeAndSameId_DontReturnErrors()
        {
            var person = new Person() { Id = 1, Age = 25 };

            var errors = new Validation<Person>(person, context)
                .IsUnique(x => x.Age)
                .ToList();

            Assert.Equal(0, errors.Count);
        }
开发者ID:Secullum,项目名称:Secullum.Validation,代码行数:10,代码来源:IsUniqueTests.cs

示例12: IsBetween_GivenValidFloatValue_DontReturnErrors

        public void IsBetween_GivenValidFloatValue_DontReturnErrors(int height)
        {
            var person = new Person() { Id = 2, Height = height};

            var errors = new Validation<Person>(person, context)
                .IsBetween(x => x.Height, 100, 250)
                .ToList();

            Assert.Equal(0, errors.Count);
        }
开发者ID:Secullum,项目名称:Secullum.Validation,代码行数:10,代码来源:IsBetweenTests.cs

示例13: IsBetween_GivenValidIntValue_DontReturnErrors

        public void IsBetween_GivenValidIntValue_DontReturnErrors(int age)
        {
            var person = new Person() { Id = 2, Age = age };

            var errors = new Validation<Person>(person, context)
                .IsBetween(x => x.Age, 18, 60)
                .ToList();

            Assert.Equal(0, errors.Count);
        }
开发者ID:Secullum,项目名称:Secullum.Validation,代码行数:10,代码来源:IsBetweenTests.cs

示例14: HasMaxLength_GivenValidField_DontReturnErrors

        public void HasMaxLength_GivenValidField_DontReturnErrors(string name, int maxLength)
        {
            var person = new Person() { Name = name };

            var errors = new Validation<Person>(person)
                .HasMaxLength(x => x.Name, maxLength)
                .ToList();

            Assert.Equal(0, errors.Count);
        }
开发者ID:Secullum,项目名称:Secullum.Validation,代码行数:10,代码来源:HasMaxLengthTests.cs

示例15: IsCnpj_GivenValidField_DontReturnErrors

        public void IsCnpj_GivenValidField_DontReturnErrors(string cnpj)
        {
            var person = new Person() { Cnpj = cnpj };

            var errors = new Validation<Person>(person)
                .IsCnpj(x => x.Cnpj)
                .ToList();

            Assert.Equal(0, errors.Count);
        }
开发者ID:Secullum,项目名称:Secullum.Validation,代码行数:10,代码来源:IsCnpjTests.cs


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