本文整理汇总了C#中IValidationErrors.GetErrors方法的典型用法代码示例。如果您正苦于以下问题:C# IValidationErrors.GetErrors方法的具体用法?C# IValidationErrors.GetErrors怎么用?C# IValidationErrors.GetErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IValidationErrors
的用法示例。
在下文中一共展示了IValidationErrors.GetErrors方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsValid
/// <summary>
/// Gets or sets a flag specifying whether this binding is valid.
/// </summary>
/// <value>
/// <c>true</c> if this binding evaluated without errors;
/// <c>false</c> otherwise.
/// </value>
public bool IsValid(IValidationErrors errors)
{
if (errors == null) return true;
IList errorList = errors.GetErrors(ALL_BINDINGERRORS_PROVIDER);
return (errorList == null) || (!errorList.Contains(this.ErrorMessage));
}
示例2: MergeErrors
/// <summary>
/// Merges another instance of <see cref="ValidationErrors"/> into this one.
/// </summary>
/// <remarks>
/// <p>
/// If the supplied <paramref name="errorsToMerge"/> is <see lang="null"/>,
/// then no errors will be added to this instance, and this method will
/// (silently) return.
/// </p>
/// </remarks>
/// <param name="errorsToMerge">
/// The validation errors to merge; can be <see lang="null"/>.
/// </param>
public void MergeErrors(IValidationErrors errorsToMerge)
{
if (errorsToMerge != null)
{
foreach(string provider in errorsToMerge.Providers)
{
List<ErrorMessage> errList;
List<ErrorMessage> other = new List<ErrorMessage>(errorsToMerge.GetErrors(provider));
if (!errorMap.TryGetValue(provider, out errList))
{
this.errorMap[provider] = other;
}
else
{
errList.AddRange(other);
}
}
// foreach (DictionaryEntry errorEntry in errorsToMerge.errorMap)
// {
// ArrayList errList = (ArrayList) this.errorMap[errorEntry.Key];
// if (errList == null)
// {
// this.errorMap[errorEntry.Key] = errorEntry.Value;
// }
// else
// {
// errList.AddRange((IList) errorEntry.Value);
// }
// }
}
}
示例3: WhenMultipleValidatorsReturnTrue
private void WhenMultipleValidatorsReturnTrue(ExclusiveValidatorGroup vg, IValidationErrors errors)
{
vg.Actions.Add(new ErrorMessageAction("exclusiveError", "exclusiveErrors"));
vg.Validators.Add(new FalseValidator());
vg.Validators.Add(new TrueValidator());
vg.Validators.Add(new TrueValidator());
vg.Validators.Add(new FalseValidator());
errors.AddError("existingErrors", new ErrorMessage("error", null));
bool valid = vg.Validate(new object(), errors);
Assert.IsFalse(valid, "Validation should not succeed when multiple inner validators return true.");
Assert.AreEqual(1, errors.GetErrors("exclusiveErrors").Count);
Assert.AreEqual(1, errors.GetErrors("existingErrors").Count);
}
示例4: MergeErrors
/// <summary>
/// Merges another instance of <see cref="ValidationErrors"/> into this one.
/// </summary>
/// <remarks>
/// <p>
/// If the supplied <paramref name="errorsToMerge"/> is <see lang="null"/>,
/// then no errors will be added to this instance, and this method will
/// (silently) return.
/// </p>
/// </remarks>
/// <param name="errorsToMerge">
/// The validation errors to merge; can be <see lang="null"/>.
/// </param>
public void MergeErrors(IValidationErrors errorsToMerge)
{
if (errorsToMerge != null)
{
foreach(string provider in errorsToMerge.Providers)
{
ArrayList errList = (ArrayList) this.errorMap[provider];
IList other = errorsToMerge.GetErrors(provider);
if (errList == null)
{
this.errorMap[provider] = other;
}
else
{
errList.AddRange((IList) other);
}
}
// foreach (DictionaryEntry errorEntry in errorsToMerge.errorMap)
// {
// ArrayList errList = (ArrayList) this.errorMap[errorEntry.Key];
// if (errList == null)
// {
// this.errorMap[errorEntry.Key] = errorEntry.Value;
// }
// else
// {
// errList.AddRange((IList) errorEntry.Value);
// }
// }
}
}