本文整理汇总了C#中IValidator类的典型用法代码示例。如果您正苦于以下问题:C# IValidator类的具体用法?C# IValidator怎么用?C# IValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IValidator类属于命名空间,在下文中一共展示了IValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateFormat
private static void ValidateFormat(List<char> delimiters, string numbers, IValidator validator)
{
if (!validator.Validate(numbers, delimiters))
{
throw new CalculatorFormatException(validator.LastErrorMessage);
}
}
示例2: TestsViewModel
public TestsViewModel(
ITestQuery queries,
ITests commands,
ISubjectQuery subjectQuery,
IValidator<Test> testValidator,
IValidator<Question> questionValidator,
IValidator<Answer> answerValidator,
IValidator<AssociatedSubject> subjectValidator
)
: base()
{
_queries = queries;
_commands = commands;
_subjectQuery = subjectQuery;
_testValidator = testValidator;
_questionValidator = questionValidator;
_answerValidator = answerValidator;
_subjectValidator = subjectValidator;
LoadAllTests();
_addTestCommand = new RelayCommand(
() => AddNewTest(),
() => CanAddNewTest()
);
}
示例3: GetValidatorsForModel
IEnumerable<ModelValidator> GetValidatorsForModel(ModelMetadata metadata, ControllerContext context,IValidator validator)
{
if (validator != null)
{
yield return new FVModelValidator(metadata, context, validator);
}
}
示例4: GenerateForValidator
void GenerateForValidator(IValidator inputValidator, TypeMetaData metaData, string parentKey, bool isParentConcept = false, bool isParentModelRule = false)
{
var inputValidatorType = inputValidator.GetType();
var genericArguments = inputValidatorType.BaseType.GetGenericArguments();
var descriptor = inputValidator.CreateDescriptor();
var members = descriptor.GetMembersWithValidators();
foreach (var member in members)
{
var rules = descriptor.GetRulesForMember(member.Key);
foreach (var rule in rules)
{
foreach (var validator in rule.Validators)
{
var isModelRule = member.Key == ModelRule<string>.ModelRulePropertyName;
var currentKey = GetKeyForMember(parentKey, isParentConcept, isParentModelRule, member, isModelRule);
if (validator is ChildValidatorAdaptor)
{
GenerateForChildValidator(metaData, genericArguments, member, validator, isModelRule, currentKey);
}
else if (validator is IPropertyValidator)
{
GenerateFor(metaData, currentKey, validator);
}
}
}
}
}
示例5: CardService
public CardService(ICardRepository cardRepository, IValidator validator, IProjectService projectService, ISession session)
{
_cardRepository = cardRepository;
_validator = validator;
_projectService = projectService;
_session = session;
}
示例6: GetCompositeResultsPrivate
private static IValidationResultCollection GetCompositeResultsPrivate(IResourceManager mgr, string rule, IValidator[] validators)
{
ValidationResultCollection results = new ValidationResultCollection(mgr, rule);
foreach (IValidator validator in validators)
results.Add(validator.Validate());
return results;
}
示例7: DoEmit
/// <summary>
/// Emit implementation starting point
/// </summary>
/// <param name="v">The v.</param>
/// <param name="sb">The sb.</param>
/// <returns></returns>
protected StringBuilder DoEmit(IValidator v, StringBuilder sb)
{
if (v.GetType().IsGenericType && typeof(ValidationSite<,>).IsAssignableFrom(v.GetType().GetGenericTypeDefinition()))
return EmitSites(v, sb);
else
return EmitNamespace(v, sb);
}
示例8: CommonValidationResult
/// <summary>
/// Initializes a new instance of the <see cref="CommonValidationResult"/> class.
/// </summary>
/// <param name="rule">The rule.</param>
/// <param name="target">The target.</param>
/// <param name="message">The message.</param>
/// <param name="success">if set to <c>true</c> [success].</param>
public CommonValidationResult(IValidator rule, IValidatable target, string message, bool success)
{
Rule = rule;
Target = target;
Message = message;
Success = success;
}
示例9: SetUp
public override void SetUp()
{
base.SetUp();
_collectionRepository = Substitute.For<IPagedCollectionRepository<Logic.Product.FindPagedCollection.ProductItem, Logic.Product.FindPagedCollection.Query>>();
_validator = Substitute.For<IValidator<Logic.Product.FindPagedCollection.Query>>();
_sut = new Logic.Product.FindPagedCollection.QueryHandler(_collectionRepository, _validator);
}
示例10: Emitter
public Emitter(IDictionary<string,
TypeDefinition> typeDefinitions,
BridgeTypes bridgeTypes,
List<ITypeInfo> types,
IValidator validator,
IMemberResolver resolver,
Dictionary<string, ITypeInfo> typeInfoDefinitions,
ILogger logger)
{
this.Log = logger;
this.Resolver = resolver;
this.TypeDefinitions = typeDefinitions;
this.TypeInfoDefinitions = typeInfoDefinitions;
this.Types = types;
this.BridgeTypes = bridgeTypes;
this.BridgeTypes.InitItems(this);
logger.Trace("Sorting types infos by name...");
this.Types.Sort(this.CompareTypeInfosByName);
logger.Trace("Sorting types infos by name done");
this.SortTypesByInheritance();
this.Validator = validator;
this.AssignmentType = ICSharpCode.NRefactory.CSharp.AssignmentOperatorType.Any;
this.UnaryOperatorType = ICSharpCode.NRefactory.CSharp.UnaryOperatorType.Any;
this.JsDoc = new JsDoc();
}
示例11: RuntimeConfiguration
public RuntimeConfiguration(ProviderInfo providerInfo, ConnectionInfo connectionInfo, IValidator validator, ISqlDispatcher sqlDispatcher)
{
_providerInfo = providerInfo;
_connectionInfo = connectionInfo;
_validator = validator;
_sqlDispatcher = sqlDispatcher;
}
示例12: InvalidMessageTransformer
public InvalidMessageTransformer(ConstraintValidatorContext constraintContext,
List<InvalidValue> results,
System.Type @class,
string propertyName /* nullable */,
object value /* nullable */,
object entity /* nullable */,
IValidator validator,
DefaultMessageInterpolatorAggregator defaultInterpolator,
IMessageInterpolator userInterpolator /* nullable */)
{
if (constraintContext == null) throw new ArgumentNullException("constraintContext");
if (results == null) throw new ArgumentNullException("results");
if (@class == null) throw new ArgumentNullException("class");
if (validator == null) throw new ArgumentNullException("valitor");
if (defaultInterpolator == null) throw new ArgumentNullException("defaultInterpolator");
this.constraintContext = constraintContext;
this.results = results;
[email protected] = @class;
this.propertyName = propertyName;
this.value = value;
this.entity = entity;
this.validator = validator;
this.defaultInterpolator = defaultInterpolator;
this.userInterpolator = userInterpolator;
}
示例13: SetUp
public override void SetUp()
{
base.SetUp();
_validator = Substitute.For<IValidator<Logic.Product.Delete.Command>>();
_repository = Substitute.For<Logic.Product.Delete.IDeleteProductRepository>();
_sut = new Logic.Product.Delete.CommandHandler(_validator, _repository);
}
示例14: EmitSites
/// <summary>
/// Emits the sites.
/// </summary>
/// <param name="v">The v.</param>
/// <param name="sb">The sb.</param>
/// <returns></returns>
private StringBuilder EmitSites(IValidator v, StringBuilder sb)
{
sb
.Append("{ field: \"")
.Append(v.Name)
.Append("\", attributes: [");
bool found = false;
foreach (IValidator child in v.Children)
{
sb.Append("{ name: \"");
sb.Append(GetSimpleTypeName(child));
sb.Append("\"");
foreach (string key in child.DefiningParams.Keys)
{
sb.Append(",");
sb.Append(key);
sb.Append(": \"");
sb.Append(new NDjango.FiltersCS.EscapeJSFilter().Perform(Convert.ToString(child.DefiningParams[key])));
sb.Append("\"");
}
sb.Append("},");
found = true;
}
if (found)
sb.Remove(sb.Length - 1, 1);
return sb.Append("]}");
}
示例15: FluentValidationModelValidator
public FluentValidationModelValidator(ModelMetadata metadata, ControllerContext controllerContext, IValidator validator)
: base(metadata, controllerContext) {
this.validator = validator;
this.customizations = CustomizeValidatorAttribute.GetFromControllerContext(controllerContext)
?? new CustomizeValidatorAttribute();
}