示例#1
0
        /// <summary>
        /// Get registrar for the given provider <br />
        /// 为给定的验证服务提供者程序提供一个注册器
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static IValidationRegistrar ForProvider(IValidationProvider provider, string name)
        {
            if (provider is null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                name = $"{provider.GetType().FullName}_{provider.GetHashCode()}";
            }

            ValidationMe.RegisterProvider(provider, name);

            return(new InternalValidationRegistrar(provider, RegisterMode.Hosted, name));
        }