本文整理汇总了C#中Validator.NoteError方法的典型用法代码示例。如果您正苦于以下问题:C# Validator.NoteError方法的具体用法?C# Validator.NoteError怎么用?C# Validator.NoteError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validator
的用法示例。
在下文中一共展示了Validator.NoteError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
internal bool Execute(
bool skipIfNoChanges, bool formValuesChanged, Action<EwfValidation, IEnumerable<string>> validationErrorHandler, bool performValidationOnly = false,
Tuple<Action, Action> actionMethodAndPostModificationMethod = null)
{
var validationNeeded = validations.Any() && ( !skipIfNoChanges || formValuesChanged );
if( validationNeeded ) {
var topValidator = new Validator();
foreach( var validation in validations ) {
if( topValidations.Contains( validation ) )
validation.Method( AppRequestState.Instance.EwfPageRequestState.PostBackValues, topValidator );
else {
var validator = new Validator();
validation.Method( AppRequestState.Instance.EwfPageRequestState.PostBackValues, validator );
if( validator.ErrorsOccurred )
topValidator.NoteError();
validationErrorHandler( validation, validator.ErrorMessages );
}
}
if( topValidator.ErrorsOccurred )
throw new DataModificationException( Translation.PleaseCorrectTheErrorsShownBelow.ToSingleElementArray().Concat( topValidator.ErrorMessages ).ToArray() );
}
var skipModification = !modificationMethods.Any() || ( skipIfNoChanges && !formValuesChanged );
if( performValidationOnly || ( skipModification && actionMethodAndPostModificationMethod == null ) )
return validationNeeded;
DataAccessState.Current.DisableCache();
try {
if( !skipModification ) {
foreach( var method in modificationMethods )
method();
}
if( actionMethodAndPostModificationMethod != null )
actionMethodAndPostModificationMethod.Item1();
DataAccessState.Current.ResetCache();
AppRequestState.Instance.PreExecuteCommitTimeValidationMethodsForAllOpenConnections();
if( actionMethodAndPostModificationMethod != null )
actionMethodAndPostModificationMethod.Item2();
}
catch {
AppRequestState.Instance.RollbackDatabaseTransactions();
DataAccessState.Current.ResetCache();
throw;
}
return true;
}
示例2: HandleResult
/// <summary>
/// If LastResult is not NoError, this method invokes the appropriate behavior according to how this error handler was created.
/// </summary>
internal void HandleResult( Validator validator, bool errorWouldResultInUnusableReturnValue )
{
if( validationResult.ErrorCondition == ErrorCondition.NoError )
return;
// if there is a custom handler, run it and do nothing else
if( customHandler != null ) {
validator.NoteError();
customHandler( validator, validationResult.ErrorCondition );
return;
}
// build the error message
string message;
if( !customMessages.TryGetValue( validationResult.ErrorCondition, out message ) )
// NOTE: Do we really need custom message, or can the custom handler manage that?
message = validationResult.GetErrorMessage( subject );
validator.AddError( new Error( message, errorWouldResultInUnusableReturnValue ) );
}