本文整理汇总了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;
}
示例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);
}
示例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;
}
}
}
示例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);
}