本文整理汇总了C#中IValidator.RegisterService方法的典型用法代码示例。如果您正苦于以下问题:C# IValidator.RegisterService方法的具体用法?C# IValidator.RegisterService怎么用?C# IValidator.RegisterService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IValidator
的用法示例。
在下文中一共展示了IValidator.RegisterService方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
/// <summary>
/// This method should be called before any of the other methods. It effectivly initializes the Validation Engine.
/// Use this overloaded method to provide your own custom validator and manager.
/// </summary>
/// <param name="validator">A <see cref="IValidator"/> representing a custom validator.</param>
/// <param name="manager">A <see cref="IValidationManager"/> representing a custom manager.</param>
/// <exception cref="System.InvalidOperationException">If the Engine has already been initialized, this will be thrown.</exception>
/// <exception cref="System.ArgumentNullException">If validator or manager are null.</exception>
public static void Initialize(IValidator validator, IValidationManager manager)
{
if (_isInitialized)
throw new InvalidOperationException("Initialization of the Validation Engine can only happen once.");
if (validator == null)
throw new ArgumentNullException("validator");
if (manager == null)
throw new ArgumentNullException("manager");
CurrentValidator = validator;
CurrentManager = manager;
CurrentValidator.RegisterService(typeof(IValidationManager), CurrentManager);
CurrentValidator.RegisterService(typeof(IValidator), CurrentValidator);
_isInitialized = true;
}