System.Xml.Schema.FacetsChecker.FacetsCompiler.CheckValue C# (CSharp) Method

CheckValue() private method

private CheckValue ( object value, XmlSchemaFacet facet ) : void
value object
facet XmlSchemaFacet
return void
        private void CheckValue(object value, XmlSchemaFacet facet) {
            RestrictionFacets restriction = datatype.Restriction;
            switch (facet.FacetType) {
                case FacetType.MaxInclusive:
                    if ((baseFlags & RestrictionFlags.MaxInclusive) != 0) { //Base facet has maxInclusive
                        if (datatype.Compare(value, restriction.MaxInclusive) > 0) {
                            throw new XmlSchemaException(Res.Sch_MaxInclusiveMismatch, string.Empty);
                        }
                    }
                    if ((baseFlags & RestrictionFlags.MaxExclusive) != 0) { //Base facet has maxExclusive
                        if (datatype.Compare(value, restriction.MaxExclusive) >= 0) {
                            throw new XmlSchemaException(Res.Sch_MaxIncExlMismatch, string.Empty);
                        }
                    }
                break;

                case FacetType.MaxExclusive:
                    if ((baseFlags & RestrictionFlags.MaxExclusive) != 0) { //Base facet has maxExclusive
                        if (datatype.Compare(value, restriction.MaxExclusive) > 0) {
                            throw new XmlSchemaException(Res.Sch_MaxExclusiveMismatch, string.Empty);
                        }
                    }
                    if ((baseFlags & RestrictionFlags.MaxInclusive) != 0) { //Base facet has maxInclusive
                        if (datatype.Compare(value, restriction.MaxInclusive) > 0) {
                            throw new XmlSchemaException(Res.Sch_MaxExlIncMismatch, string.Empty);
                        }
                    }
                break;

                case FacetType.MinInclusive:
                    if ((baseFlags & RestrictionFlags.MinInclusive) != 0) { //Base facet has minInclusive
                        if (datatype.Compare(value, restriction.MinInclusive) < 0) {
                            throw new XmlSchemaException(Res.Sch_MinInclusiveMismatch, string.Empty);
                        }
                    }
                    if ((baseFlags & RestrictionFlags.MinExclusive) != 0) { //Base facet has minExclusive
                        if (datatype.Compare(value, restriction.MinExclusive) < 0) {
                            throw new XmlSchemaException(Res.Sch_MinIncExlMismatch, string.Empty);
                        }
                    }
                    if ((baseFlags & RestrictionFlags.MaxExclusive) != 0) { //Base facet has maxExclusive
                        if (datatype.Compare(value, restriction.MaxExclusive) >= 0) {
                            throw new XmlSchemaException(Res.Sch_MinIncMaxExlMismatch, string.Empty);
                        }
                    }
                break;

                case FacetType.MinExclusive:
                    if ((baseFlags & RestrictionFlags.MinExclusive) != 0) { //Base facet has minExclusive
                        if (datatype.Compare(value, restriction.MinExclusive) < 0) {
                            throw new XmlSchemaException(Res.Sch_MinExclusiveMismatch, string.Empty);
                        }
                    }
                    if ((baseFlags & RestrictionFlags.MinInclusive) != 0) { //Base facet has minInclusive
                        if (datatype.Compare(value, restriction.MinInclusive) < 0) {
                            throw new XmlSchemaException(Res.Sch_MinExlIncMismatch, string.Empty);
                        }
                    }
                    if ((baseFlags & RestrictionFlags.MaxExclusive) != 0) { //Base facet has maxExclusive
                        if (datatype.Compare(value, restriction.MaxExclusive) >= 0) {
                            throw new XmlSchemaException(Res.Sch_MinExlMaxExlMismatch, string.Empty);
                        }
                    }
                break;

                default:
                    Debug.Assert(false);
                break;
            }
        }