本文整理汇总了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();
}
示例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;
}
示例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);
}
示例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;
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}