本文整理汇总了C#中IValidationErrors类的典型用法代码示例。如果您正苦于以下问题:C# IValidationErrors类的具体用法?C# IValidationErrors怎么用?C# IValidationErrors使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IValidationErrors类属于命名空间,在下文中一共展示了IValidationErrors类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ValidateGroup
/// <summary>
/// Actual implementation how to validate the specified object.
/// </summary>
/// <param name="contextParams">Additional context parameters.</param>
/// <param name="errors"><see cref="ValidationErrors"/> instance to add error messages to.</param>
/// <param name="validationContext">The object to validate.</param>
/// <returns><c>True</c> if validation was successful, <c>False</c> otherwise.</returns>
protected override bool ValidateGroup(IDictionary<string, object> contextParams, IValidationErrors errors, object validationContext)
{
ValidationErrors tmpErrors = new ValidationErrors();
bool valid = false;
foreach (IValidator validator in Validators)
{
bool tmpValid = validator.Validate(validationContext, contextParams, tmpErrors);
if (valid && tmpValid)
{
valid = false;
if (this.FastValidate)
{
break;
}
}
else if (tmpValid)
{
valid = true;
}
}
if (!valid)
{
errors.MergeErrors(tmpErrors);
}
return valid;
}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:35,代码来源:ExclusiveValidatorGroup.cs
示例2: 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));
}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:14,代码来源:AbstractBinding.cs
示例3: ValidationException
/// <summary>Constructor</summary>
/// <param name="errors">Validation errors</param>
public ValidationException(IValidationErrors errors)
: base(errors.ToExceptionMessage())
{
Checker.ArgumentIsNull(errors, "errors");
Errors = errors;
}
开发者ID:dilterporto,项目名称:Validator,代码行数:9,代码来源:ValidationException.cs
示例4: AddValidationErrors
/// <summary>
/// 把錯誤訊息記錄到IValidationDictionary的物件裡面
/// </summary>
/// <param name="validationDictionary">儲存目前Validation結果的Dictionary</param>
/// <param name="propertyErrors">要記錄到ValidationDictionary裡面的錯誤訊息</param>
public static void AddValidationErrors(this IValidationDictionary validationDictionary, IValidationErrors propertyErrors)
{
foreach (var databaseValidationError in propertyErrors.Errors)
{
validationDictionary.AddError(databaseValidationError.PropertyName, databaseValidationError.PropertyExceptionMessage);
}
}
开发者ID:matsurigoto,项目名称:mvc-base-project,代码行数:12,代码来源:ValidationErrorExtension.cs
示例5: OnInvalid
/// <summary>
/// Called when associated validator is invalid.
/// </summary>
/// <param name="validationContext">Validation context.</param>
/// <param name="contextParams">Additional context parameters.</param>
/// <param name="errors">Validation errors container.</param>
protected override void OnInvalid(object validationContext, IDictionary<string, object> contextParams, IValidationErrors errors)
{
ErrorMessage error = CreateErrorMessage(validationContext, contextParams);
foreach (string provider in this.providers)
{
errors.AddError(provider.Trim(), error);
}
}
开发者ID:Binodesk,项目名称:spring-net,代码行数:14,代码来源:ErrorMessageAction.cs
示例6: ConsumeErrors
protected void ConsumeErrors(IValidationErrors errors)
{
//ModelState.Clear();
foreach (IValidationError error in errors)
{
ConsumeError(error);
}
}
开发者ID:ejbaling,项目名称:Blueapps,代码行数:8,代码来源:BaseController.cs
示例7: BindTargetToSource
/// <summary>
/// Binds target object to source object.
/// </summary>
/// <param name="source">
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// </param>
public override void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary<string, object> variables)
{
if (variables == null)
{
variables = new Dictionary<string, object>();
}
variables["source"] = source;
variables["target"] = target;
sourceExpression.GetValue(null, variables);
}
开发者ID:Binodesk,项目名称:spring-net,代码行数:26,代码来源:ListBinding.cs
示例8: BindSourceToTarget
/// <summary>
/// Binds source object to target object.
/// </summary>
/// <param name="source">
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// </param>
public override void BindSourceToTarget(object source, object target, IValidationErrors validationErrors,
IDictionary variables)
{
if (variables == null)
{
variables = new Hashtable();
}
variables["source"] = source;
variables["target"] = target;
targetExpression.GetValue(null, variables);
}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:27,代码来源:ListBinding.cs
示例9: SetInvalid
/// <summary>
/// Marks this binding's state as invalid for this validationErrors collection.
/// Returns false if <paramref name="validationErrors"/> is null.
/// </summary>
/// <param name="validationErrors"></param>
/// <returns>false, if validationErrors is null</returns>
protected bool SetInvalid(IValidationErrors validationErrors)
{
if (validationErrors != null)
{
foreach (string provider in this.ErrorProviders)
{
validationErrors.AddError(provider, this.ErrorMessage);
}
return true;
}
return false;
}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:18,代码来源:AbstractBinding.cs
示例10: ValidateGroup
/// <summary>
/// Actual implementation how to validate the specified object.
/// </summary>
/// <param name="validationContext">The object to validate.</param>
/// <param name="contextParams">Additional context parameters.</param>
/// <param name="errors"><see cref="ValidationErrors"/> instance to add error messages to.</param>
/// <returns><c>True</c> if validation was successful, <c>False</c> otherwise.</returns>
protected override bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext)
{
bool valid = true;
foreach (IValidator validator in this.Validators)
{
valid = validator.Validate(validationContext, contextParams, errors) && valid;
if (!valid && this.FastValidate)
{
break;
}
}
return valid;
}
开发者ID:fuadm,项目名称:spring-net,代码行数:20,代码来源:ValidatorGroup.cs
示例11: Execute
/// <summary>
/// Executes the action.
/// </summary>
/// <param name="isValid">Whether associated validator is valid or not.</param>
/// <param name="validationContext">Validation context.</param>
/// <param name="contextParams">Additional context parameters.</param>
/// <param name="errors">Validation errors container.</param>
public virtual void Execute(bool isValid, object validationContext, IDictionary contextParams, IValidationErrors errors)
{
if (EvaluateWhen(validationContext, contextParams))
{
if (isValid)
{
OnValid(validationContext, contextParams, errors);
}
else
{
OnInvalid(validationContext, contextParams, errors);
}
}
}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:21,代码来源:BaseValidationAction.cs
示例12: BindSourceToTarget
/// <summary>
/// Binds source object to target object.
/// </summary>
/// <param name="source">
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// </param>
public override void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary<string, object> variables)
{
if (this.IsValid(validationErrors)
&& (this.Direction == BindingDirection.Bidirectional || this.Direction == BindingDirection.SourceToTarget))
{
try
{
DoBindSourceToTarget(source, target, variables);
}
catch (Exception)
{
if (!SetInvalid(validationErrors)) throw;
}
}
}
开发者ID:fgq841103,项目名称:spring-net,代码行数:30,代码来源:AbstractSimpleBinding.cs
示例13: ValidateGroup
/// <summary>
/// Validates the specified object.
/// </summary>
/// <param name="contextParams">Additional context parameters.</param>
/// <param name="errors"><see cref="ValidationErrors"/> instance to add error messages to.</param>
/// <param name="validationContext">The object to validate.</param>
/// <returns><c>True</c> if validation was successful, <c>False</c> otherwise.</returns>
protected override bool ValidateGroup(IDictionary<string, object> contextParams, IValidationErrors errors, object validationContext)
{
// capture errors in separate collection to only add them to the error collector in case of errors
ValidationErrors tmpErrors = new ValidationErrors();
bool valid = false;
foreach (IValidator validator in Validators)
{
valid = validator.Validate(validationContext, contextParams, tmpErrors) || valid;
if (valid && FastValidate)
{
break;
}
}
if (!valid)
{
errors.MergeErrors(tmpErrors);
}
return valid;
}
开发者ID:Binodesk,项目名称:spring-net,代码行数:27,代码来源:AnyValidatorGroup.cs
示例14: OnInvalid
/// <summary>
/// Called when associated validator is invalid.
/// </summary>
/// <param name="validationContext">Validation context.</param>
/// <param name="contextParams">Additional context parameters.</param>
/// <param name="errors">Validation errors container.</param>
protected override void OnInvalid(object validationContext, IDictionary<string, object> contextParams, IValidationErrors errors)
{
if (throwsExpression != null)
{
object o = null;
try
{
o = throwsExpression.GetValue(null, contextParams);
}
catch (Exception e)
{
log.Error("Was not able to evaluate action expression [" + throwsExpression + "]", e);
}
Exception exception = o as Exception;
if (exception != null)
{
throw exception;
}
}
throw new ValidationException(errors);
}
开发者ID:fgq841103,项目名称:spring-net,代码行数:27,代码来源:ExceptionAction.cs
示例15: 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);
// }
// }
}
}
开发者ID:Binodesk,项目名称:spring-net,代码行数:44,代码来源:ValidationErrors.cs
示例16: BindTargetToSource
/// <summary>
/// Binds target object to source object.
/// </summary>
/// <param name="source">
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// </param>
public abstract void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary variables);
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:16,代码来源:AbstractBinding.cs
示例17: ValidateGroup
/// <summary>
/// Actual implementation how to validate the specified object.
/// </summary>
/// <param name="validationContext">The object to validate.</param>
/// <param name="contextParams">Additional context parameters.</param>
/// <param name="errors"><see cref="ValidationErrors"/> instance to add error messages to.</param>
/// <returns><c>True</c> if validation was successful, <c>False</c> otherwise.</returns>
protected abstract bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext);
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:8,代码来源:BaseValidatorGroup.cs
示例18: Validate
/// <summary>
/// Validates the specified object.
/// </summary>
/// <param name="validationContext">The object to validate.</param>
/// <param name="contextParams">Additional context parameters.</param>
/// <param name="errors"><see cref="ValidationErrors"/> instance to add error messages to.</param>
/// <returns><c>True</c> if validation was successful, <c>False</c> otherwise.</returns>
public bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors)
{
bool valid = true;
if (When == null ||
Convert.ToBoolean(When.GetValue(validationContext, contextParams)))
{
if (Context != null)
{
validationContext = Context.GetValue(validationContext, contextParams);
}
if (validator == null)
{
validator = (IValidator)objectFactory.GetObject(Name);
}
valid = validator.Validate(validationContext, contextParams, errors);
}
return valid;
}
开发者ID:likesea,项目名称:spring.net,代码行数:27,代码来源:ValidatorReference.cs
示例19: ValidateGroup
/// <summary>
/// Actual implementation how to validate the specified object.
/// </summary>
/// <param name="validationContext">The object to validate.</param>
/// <param name="contextParams">Additional context parameters.</param>
/// <param name="errors"><see cref="ValidationErrors"/> instance to add error messages to.</param>
/// <returns><c>True</c> if validation was successful, <c>False</c> otherwise.</returns>
protected override bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext)
{
bool valid = true;
IEnumerable collectionToValidate = (validationContext is IDictionary
? ((IDictionary) validationContext).Values
: (IEnumerable) validationContext);
// decide whether to pass new validation errors collection
//(and discard error messages returned by the item validators)
// OR to pass validation errors collection that was passed to this method
//(and collect all error messages returned by the item validators)
IValidationErrors err = (includeElementErrors)? errors : new ValidationErrors();
foreach (object objectToValidate in collectionToValidate)
{
foreach (IValidator validator in this.Validators)
{
valid = validator.Validate(objectToValidate, contextParams, err) && valid;
if (!valid && this.FastValidate)
{
break;
}
}
if (!valid && this.FastValidate)
{
break;
}
}
return valid;
}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:38,代码来源:CollectionValidator.cs
示例20: ProcessActions
/// <summary>
/// Processes the error messages.
/// </summary>
/// <param name="isValid">Whether validator is valid or not.</param>
/// <param name="validationContext">Validation context.</param>
/// <param name="contextParams">Additional context parameters.</param>
/// <param name="errors">Validation errors container.</param>
protected void ProcessActions(bool isValid, object validationContext, IDictionary contextParams, IValidationErrors errors)
{
if (actions != null && actions.Count > 0)
{
foreach (IValidationAction action in actions)
{
action.Execute(isValid, validationContext, contextParams, errors);
}
}
}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:17,代码来源:BaseValidator.cs
注:本文中的IValidationErrors类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论