internal bool MatchEnumeration(decimal value, ArrayList enumeration, XmlValueConverter valueConverter)
 {
     for (int i = 0; i < enumeration.Count; i++)
     {
         if (value == valueConverter.ToDecimal(enumeration[i]))
         {
             return(true);
         }
     }
     return(false);
 }
        internal override Exception CheckValueFacets(decimal value, XmlSchemaDatatype datatype)
        {
            RestrictionFacets restriction    = datatype.Restriction;
            RestrictionFlags  flags          = (restriction != null) ? restriction.Flags : ((RestrictionFlags)0);
            XmlValueConverter valueConverter = datatype.ValueConverter;

            if ((value > this.maxValue) || (value < this.minValue))
            {
                return(new OverflowException(Res.GetString("XmlConvert_Overflow", new object[] { value.ToString(CultureInfo.InvariantCulture), datatype.TypeCodeString })));
            }
            if (flags == 0)
            {
                return(null);
            }
            if (((flags & RestrictionFlags.MaxInclusive) != 0) && (value > valueConverter.ToDecimal(restriction.MaxInclusive)))
            {
                return(new XmlSchemaException("Sch_MaxInclusiveConstraintFailed", string.Empty));
            }
            if (((flags & RestrictionFlags.MaxExclusive) != 0) && (value >= valueConverter.ToDecimal(restriction.MaxExclusive)))
            {
                return(new XmlSchemaException("Sch_MaxExclusiveConstraintFailed", string.Empty));
            }
            if (((flags & RestrictionFlags.MinInclusive) != 0) && (value < valueConverter.ToDecimal(restriction.MinInclusive)))
            {
                return(new XmlSchemaException("Sch_MinInclusiveConstraintFailed", string.Empty));
            }
            if (((flags & RestrictionFlags.MinExclusive) != 0) && (value <= valueConverter.ToDecimal(restriction.MinExclusive)))
            {
                return(new XmlSchemaException("Sch_MinExclusiveConstraintFailed", string.Empty));
            }
            if (((flags & RestrictionFlags.Enumeration) != 0) && !this.MatchEnumeration(value, restriction.Enumeration, valueConverter))
            {
                return(new XmlSchemaException("Sch_EnumerationConstraintFailed", string.Empty));
            }
            return(this.CheckTotalAndFractionDigits(value, restriction.TotalDigits, restriction.FractionDigits, (flags & RestrictionFlags.TotalDigits) != 0, (flags & RestrictionFlags.FractionDigits) != 0));
        }
Exemple #3
0
 internal bool MatchEnumeration(decimal value, ArrayList enumeration, XmlValueConverter valueConverter) {
     for (int i = 0; i < enumeration.Count; ++i) {
         if (value == valueConverter.ToDecimal(enumeration[i])) {
             return true;
         }
     }
     return false;
 }
 internal bool MatchEnumeration(decimal value, ArrayList enumeration, XmlValueConverter valueConverter) {
     foreach(object correctValue in enumeration) {
         if (value == valueConverter.ToDecimal(correctValue)) {
             return true;
         }
     }
     return false;
 }