예제 #1
0
            // Token: 0x06000017 RID: 23 RVA: 0x000028A4 File Offset: 0x00000AA4
            public override PropertyConstraintViolationError Validate(object value, PropertyDefinition propertyDefinition, IPropertyBag propertyBag)
            {
                Exception ex = null;

                try
                {
                    int culture = Convert.ToInt32(value);
                    CultureInfo.GetCultureInfo(culture);
                }
                catch (FormatException ex2)
                {
                    ex = ex2;
                }
                catch (InvalidCastException ex3)
                {
                    ex = ex3;
                }
                catch (OverflowException ex4)
                {
                    ex = ex4;
                }
                catch (CultureNotFoundException)
                {
                    return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationEnumValueNotAllowed(value.ToString()), propertyDefinition, value, this));
                }
                if (ex != null)
                {
                    return(new PropertyConstraintViolationError(DataStrings.PropertyTypeMismatch(value.GetType().ToString(), typeof(int).ToString()), propertyDefinition, value, this));
                }
                return(null);
            }
예제 #2
0
            // Token: 0x06000019 RID: 25 RVA: 0x00002958 File Offset: 0x00000B58
            public override PropertyConstraintViolationError Validate(object value, PropertyDefinition propertyDefinition, IPropertyBag propertyBag)
            {
                string text = value.ToString();

                if (string.IsNullOrEmpty(text))
                {
                    return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationValueIsNullOrEmpty, propertyDefinition, value, this));
                }
                try
                {
                    if (ExTimeZone.UtcTimeZone.Id.Equals(text, StringComparison.Ordinal))
                    {
                        return(null);
                    }
                    ExTimeZoneValue.Parse(text);
                }
                catch (FormatException)
                {
                    return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationEnumValueNotAllowed(value.ToString()), propertyDefinition, value, this));
                }
                return(null);
            }