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


C# IPropertyValidator.GetType方法代码示例

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


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

示例1: GetModelValidator

        private ModelValidator GetModelValidator(ModelMetadata meta, ControllerContext context, IPropertyValidator propertyValidator)
        {
            var type = propertyValidator.GetType();
            var factory = validatorFactories
                .Where(x => x.Key.IsAssignableFrom(type))
                .Select(x => x.Value)
                .FirstOrDefault() ?? FluentValidationPropertyValidator.Create;

            return factory(meta, context, propertyValidator);
        }
开发者ID:rsmolnikov,项目名称:FluentValidation,代码行数:10,代码来源:ExtendedFluentValidationModelValidatorProvider.cs

示例2: GetValidator

 private static IValidator GetValidator(IPropertyValidator inlineval, IValidator val)
 {
     var valtype = inlineval.GetType();
     if (valtype == typeof (ChildCollectionValidatorAdaptor))
         val = ((ChildCollectionValidatorAdaptor) inlineval).Validator;
     else if (valtype == typeof (ChildValidatorAdaptor))
         val = ((ChildValidatorAdaptor) inlineval).Validator;
     else if (valtype == typeof (DelegatingValidator))
         val = GetValidator(((DelegatingValidator) inlineval).InnerValidator, val);
     return val;
 }
开发者ID:schotime,项目名称:SchoStack,代码行数:11,代码来源:FluentValidatorFinder.cs

示例3: Create

        /// <summary>
        /// Creates a <see cref="IFluentAdapter"/> instance based on the provided <paramref name="rule"/> and <paramref name="propertyValidator"/>.
        /// </summary>
        /// <param name="rule">The <see cref="PropertyRule"/> for which the adapter should be created.</param>
        /// <param name="propertyValidator">The <see cref="IPropertyValidator"/> for which the adapter should be created.</param>
        /// <returns>An <see cref="IFluentAdapter"/> instance.</returns>
        public IFluentAdapter Create(PropertyRule rule, IPropertyValidator propertyValidator)
        {
            Func<PropertyRule, IPropertyValidator, IFluentAdapter> factory;

            if (!factories.TryGetValue(propertyValidator.GetType(), out factory))
            {
                factory = (a, d) => new FluentAdapter("Custom", rule, propertyValidator);
            }

            return factory(rule, propertyValidator);
        }
开发者ID:RobertTheGrey,项目名称:Nancy,代码行数:17,代码来源:DefaultFluentAdapterFactory.cs

示例4: GenerateFor

#pragma warning restore 1591 // Xml Comments

        void GenerateFor(ValidationMetaData metaData, string property, IPropertyValidator validator)
        {
            var validatorType = validator.GetType();
            var types = new List<Type>();
            types.Add(validatorType);
            types.AddRange(validatorType.GetInterfaces());
            foreach (var type in types)
            {
                if (_generatorsByType.ContainsKey(type))
                {
                    var rule = _generatorsByType[type].GeneratorFrom(validator);
                    var ruleName = rule.GetType().Name.ToCamelCase();
                    var propertyName = property.ToCamelCase();
                    metaData[propertyName][ruleName] = rule;
                }
            }
        }
开发者ID:TormodHystad,项目名称:Bifrost,代码行数:19,代码来源:ValidationMetaDataGenerator.cs

示例5: GetModelValidator

		protected ModelValidator GetModelValidator(ModelMetadata meta, ControllerContext context, PropertyRule rule, IPropertyValidator propertyValidator) {
			var type = propertyValidator.GetType();
			
			var factory = validatorFactories
				.Where(x => x.Key.IsAssignableFrom(type))
				.Select(x => x.Value)
				.FirstOrDefault() ?? ((metadata, controllerContext, description, validator) => new FluentValidationPropertyValidator(metadata, controllerContext, description, validator));

			return factory(meta, context, rule, propertyValidator);
		}
开发者ID:calebjenkins,项目名称:FluentValidation,代码行数:10,代码来源:FluentValidationModelValidatorProvider.cs


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