/// <summary>
		/// Constructs and configures an <see cref="IValidator"/>
		/// instance based on the properties set on the attribute instance.
		/// </summary>
		/// <returns></returns>
		public override IValidator Build()
		{
			IValidator validator = new SameAsValidator(propertyToCompare);

			ConfigureValidatorMessage(validator);

			return validator;
		}
Ejemplo n.º 2
0
        /// <summary>
        /// Constructs and configures an <see cref="IValidator"/>
        /// instance based on the properties set on the attribute instance.
        /// </summary>
        /// <returns></returns>
        public override IValidator Build()
        {
            IValidator validator = new SameAsValidator(propertyToCompare);

            ConfigureValidatorMessage(validator);

            return(validator);
        }
		public void Init()
		{
			Thread.CurrentThread.CurrentCulture =
				Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

			validator1 = new SameAsValidator("ComparableField1");
			validator1.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField1"));

			validator2 = new SameAsValidator("ComparableField2");
			validator2.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField2"));

			// Use public field instead of public property
			validator3 = new SameAsValidator("ComparableField3");
			validator3.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField1"));

			target = new TestTarget();
		}
Ejemplo n.º 4
0
        public void Init()
        {
            Thread.CurrentThread.CurrentCulture       =
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

            validator1 = new SameAsValidator("ComparableField1");
            validator1.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField1"));

            validator2 = new SameAsValidator("ComparableField2");
            validator2.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField2"));

            // Use public field instead of public property
            validator3 = new SameAsValidator("ComparableField3");
            validator3.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField1"));

            validator4 = new SameAsValidator("NestedField.ComparableField1");
            validator4.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField1"));

            target             = new TestTarget();
            target.NestedField = new NestedTargetClass();
        }