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


C# Validator.AddError方法代码示例

本文整理汇总了C#中Validator.AddError方法的典型用法代码示例。如果您正苦于以下问题:C# Validator.AddError方法的具体用法?C# Validator.AddError怎么用?C# Validator.AddError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validator的用法示例。


在下文中一共展示了Validator.AddError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidatePathCharacters

 internal static void ValidatePathCharacters(string folder, string pathPart, Validator validator)
 {
     var invalidChars = GetInvalidPathChars();
     var invalidCharsInPath = folder.Where(invalidChars.Contains);
     if (invalidCharsInPath.Any())
     {
         validator.AddError<InvalidPathException>("The {1} '{2}' in the path '{0}' contains the invalid character '{3}'", pathPart, folder, invalidCharsInPath.First());
     }
 }
开发者ID:toroso,项目名称:fs4net,代码行数:9,代码来源:FolderUtils.cs

示例2: DriveParser

        public DriveParser(string rootedPath, Validator validator)
        {
            _rootedPath = rootedPath;
            _validator = validator;
            _isRooted = true;

            _driveName = ExtractMappedDrive();
            if (_driveName != null) return;

            _driveName = ExtractNetworkDrive();
            if (_driveName != null) return;

            _isRooted = false;
            _validator.AddError<NonRootedPathException>("The path '{0}' is not rooted.");
        }
开发者ID:toroso,项目名称:fs4net,代码行数:15,代码来源:DriveParser.cs

示例3: 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 ) );
        }
开发者ID:william-gross,项目名称:enterprise-web-library,代码行数:23,代码来源:ValidationErrorHandler.cs


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