internal virtual Exception CheckLexicalFacets(ref string parsedString, object value, NameTable nameTable, XNamespaceResolver resolver, SimpleTypeValidator type) { Exception exception; Xml.Schema.Linq.RestrictionFacets facets = type.RestrictionFacets; if ((facets == null ? false : facets.HasLexicalFacets)) { Xml.Schema.Linq.RestrictionFlags flags = facets.Flags; Xml.Schema.Linq.XmlSchemaWhiteSpace wsPattern = Xml.Schema.Linq.XmlSchemaWhiteSpace.Collapse; if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.WhiteSpace) != 0) { if (facets.WhiteSpace == Xml.Schema.Linq.XmlSchemaWhiteSpace.Collapse) { wsPattern = Xml.Schema.Linq.XmlSchemaWhiteSpace.Collapse; } else if (facets.WhiteSpace == Xml.Schema.Linq.XmlSchemaWhiteSpace.Preserve) { wsPattern = Xml.Schema.Linq.XmlSchemaWhiteSpace.Preserve; } } exception = this.CheckLexicalFacets(ref parsedString, type, facets.Patterns, wsPattern); } else { exception = null; } return(exception); }
internal void CheckWhitespaceFacets(ref string s, SimpleTypeValidator type, Xml.Schema.Linq.XmlSchemaWhiteSpace wsPattern) { Xml.Schema.Linq.RestrictionFacets restriction = type.RestrictionFacets; if (type.Variety == XmlSchemaDatatypeVariety.List) { s = s.Trim(); } else if (type.Variety == XmlSchemaDatatypeVariety.Atomic) { XmlSchemaDatatype datatype = type.DataType; if (datatype.GetBuiltInWSFacet() == Xml.Schema.Linq.XmlSchemaWhiteSpace.Collapse) { s = Xml.Schema.Linq.XmlComplianceUtil.NonCDataNormalize(s); } else if (datatype.GetBuiltInWSFacet() == Xml.Schema.Linq.XmlSchemaWhiteSpace.Replace) { s = Xml.Schema.Linq.XmlComplianceUtil.CDataNormalize(s); } else if (restriction != null & (int)(restriction.Flags & Xml.Schema.Linq.RestrictionFlags.WhiteSpace) != 0) { if (restriction.WhiteSpace == Xml.Schema.Linq.XmlSchemaWhiteSpace.Replace) { s = Xml.Schema.Linq.XmlComplianceUtil.CDataNormalize(s); } else if (restriction.WhiteSpace == Xml.Schema.Linq.XmlSchemaWhiteSpace.Collapse) { s = Xml.Schema.Linq.XmlComplianceUtil.NonCDataNormalize(s); } } } }
internal override Exception CheckValueFacets(object value, SimpleTypeValidator type) { Exception linqToXsdFacetException; Xml.Schema.Linq.RestrictionFacets facets = type.RestrictionFacets; if ((facets == null ? false : facets.HasValueFacets)) { Xml.Schema.Linq.RestrictionFlags flags = facets.Flags; XmlSchemaDatatype datatype = type.DataType; if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.Enumeration) != 0) { if (!this.MatchEnumeration(value, facets.Enumeration, datatype)) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.Enumeration, facets.Enumeration, value); return(linqToXsdFacetException); } } linqToXsdFacetException = null; } else { linqToXsdFacetException = null; } return(linqToXsdFacetException); }
internal SimpleTypeValidator(XmlSchemaDatatypeVariety variety, XmlSchemaSimpleType type, Xml.Schema.Linq.FacetsChecker facetsChecker, Xml.Schema.Linq.RestrictionFacets facets) { this.restrictionFacets = facets; this.facetsChecker = facetsChecker; this.dataType = type.Datatype; this.variety = variety; }
internal override Exception CheckValueFacets(object value, SimpleTypeValidator type) { Exception linqToXsdFacetException; Xml.Schema.Linq.RestrictionFacets facets = type.RestrictionFacets; if ((facets == null ? false : facets.HasValueFacets)) { IList listValue = null; Exception e = ListSimpleTypeValidator.ToList(value, ref listValue); if (e == null) { int length = listValue.Count; XmlSchemaDatatype datatype = type.DataType; Xml.Schema.Linq.RestrictionFlags flags = facets.Flags; if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.Enumeration) != 0) { if (!this.MatchEnumeration(value, facets.Enumeration, datatype)) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.Enumeration, facets.Enumeration, value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.Length) != 0) { if (length != facets.Length) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.Length, (object)facets.Length, value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MaxLength) != 0) { if (length > facets.MaxLength) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MaxLength, (object)facets.MaxLength, value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MinLength) != 0) { if (length < facets.MinLength) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MinLength, (object)facets.MinLength, value); return(linqToXsdFacetException); } } linqToXsdFacetException = null; } else { linqToXsdFacetException = e; } } else { linqToXsdFacetException = null; } return(linqToXsdFacetException); }
internal Exception CheckValueFacets(string value, SimpleTypeValidator type, bool verifyUri) { Exception linqToXsdFacetException; int length = value.Length; Xml.Schema.Linq.RestrictionFacets facets = type.RestrictionFacets; if (facets != null) { Xml.Schema.Linq.RestrictionFlags flags = facets.Flags; XmlSchemaDatatype datatype = type.DataType; Exception exception = this.CheckBuiltInFacets(value, datatype.TypeCode, verifyUri); if (exception == null) { if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.Enumeration) != 0) { if (!this.MatchEnumeration(value, facets.Enumeration, datatype)) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.Enumeration, facets.Enumeration, value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.Length) != 0) { if (length != facets.Length) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.Length, (object)facets.Length, value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MaxLength) != 0) { if (length > facets.MaxLength) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MaxLength, (object)facets.MaxLength, value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MinLength) != 0) { if (length < facets.MinLength) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MinLength, (object)facets.MinLength, value); return(linqToXsdFacetException); } } linqToXsdFacetException = null; } else { linqToXsdFacetException = exception; } } else { linqToXsdFacetException = null; } return(linqToXsdFacetException); }
internal override Exception CheckValueFacets(TimeSpan value, SimpleTypeValidator type) { Exception linqToXsdFacetException; Xml.Schema.Linq.RestrictionFacets facets = type.RestrictionFacets; if ((facets == null ? false : facets.HasValueFacets)) { Xml.Schema.Linq.RestrictionFlags flags = facets.Flags; XmlSchemaDatatype datatype = type.DataType; if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.Enumeration) != 0) { if (!this.MatchEnumeration(value, facets.Enumeration, datatype)) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.Enumeration, facets.Enumeration, (object)value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MaxInclusive) != 0) { if (TimeSpan.Compare(value, (TimeSpan)datatype.ChangeType(facets.MaxInclusive, typeof(TimeSpan))) > 0) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MaxInclusive, facets.MaxInclusive, (object)value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MaxExclusive) != 0) { if (TimeSpan.Compare(value, (TimeSpan)datatype.ChangeType(facets.MaxExclusive, typeof(TimeSpan))) >= 0) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MaxExclusive, facets.MaxExclusive, (object)value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MinInclusive) != 0) { if (TimeSpan.Compare(value, (TimeSpan)datatype.ChangeType(facets.MinInclusive, typeof(TimeSpan))) < 0) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MaxExclusive, facets.MinInclusive, (object)value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MinExclusive) != 0) { if (TimeSpan.Compare(value, (TimeSpan)datatype.ChangeType(facets.MinExclusive, typeof(TimeSpan))) <= 0) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MaxExclusive, facets.MinExclusive, (object)value); return(linqToXsdFacetException); } } linqToXsdFacetException = null; } else { linqToXsdFacetException = null; } return(linqToXsdFacetException); }
internal override Exception CheckValueFacets(XmlQualifiedName value, SimpleTypeValidator type) { Exception linqToXsdFacetException; Xml.Schema.Linq.RestrictionFacets facets = type.RestrictionFacets; if (!(facets == null ? false : facets.HasValueFacets)) { linqToXsdFacetException = null; } else if (facets != null) { Xml.Schema.Linq.RestrictionFlags flags = facets.Flags; XmlSchemaDatatype datatype = type.DataType; if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.Enumeration) != 0) { if (!this.MatchEnumeration(value, facets.Enumeration, datatype)) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.Enumeration, facets.Enumeration, value); return(linqToXsdFacetException); } } int length = value.ToString().Length; if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.Length) != 0) { if (length != facets.Length) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.Length, (object)facets.Length, value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MaxLength) != 0) { if (length > facets.MaxLength) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MaxLength, (object)facets.MaxLength, value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MinLength) != 0) { if (length < facets.MinLength) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MinLength, (object)facets.MinLength, value); return(linqToXsdFacetException); } } linqToXsdFacetException = null; } else { linqToXsdFacetException = null; } return(linqToXsdFacetException); }
public ListSimpleTypeValidator(XmlSchemaSimpleType type, Xml.Schema.Linq.RestrictionFacets facets, SimpleTypeValidator itemType) : base(XmlSchemaDatatypeVariety.List, type, Xml.Schema.Linq.FacetsChecker.ListFacetsChecker, facets) { this.itemType = itemType; }
public UnionSimpleTypeValidator(XmlSchemaSimpleType type, Xml.Schema.Linq.RestrictionFacets facets, SimpleTypeValidator[] memberTypes) : base(XmlSchemaDatatypeVariety.Union, type, Xml.Schema.Linq.FacetsChecker.UnionFacetsChecker, facets) { this.memberTypes = memberTypes; }
public AtomicSimpleTypeValidator(XmlSchemaSimpleType type, Xml.Schema.Linq.RestrictionFacets facets) : base(XmlSchemaDatatypeVariety.Atomic, type, Xml.Schema.Linq.FacetsChecker.GetFacetsChecker(type.Datatype.TypeCode), facets) { }
internal override Exception CheckValueFacets(decimal value, SimpleTypeValidator type) { Exception linqToXsdFacetException; Xml.Schema.Linq.RestrictionFacets facets = type.RestrictionFacets; if ((facets == null ? false : facets.HasValueFacets)) { Xml.Schema.Linq.RestrictionFlags flags = facets.Flags; XmlSchemaDatatype datatype = type.DataType; if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.Enumeration) != 0) { if (!this.MatchEnumeration(value, facets.Enumeration, datatype)) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.Enumeration, facets.Enumeration, (object)value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.FractionDigits) != 0) { if (base.CheckTotalAndFractionDigits(value, 29, facets.FractionDigits, false, true) != null) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.FractionDigits, (object)facets.FractionDigits, (object)value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MaxExclusive) != 0) { if (value >= (decimal)datatype.ChangeType(facets.MaxExclusive, typeof(decimal))) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MaxExclusive, facets.MaxExclusive, (object)value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MaxInclusive) != 0) { if (value > (decimal)datatype.ChangeType(facets.MaxInclusive, typeof(decimal))) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MaxInclusive, facets.MaxInclusive, (object)value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MinExclusive) != 0) { if (value <= (decimal)datatype.ChangeType(facets.MinExclusive, typeof(decimal))) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MinExclusive, facets.MinExclusive, (object)value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MinInclusive) != 0) { if (value < (decimal)datatype.ChangeType(facets.MinInclusive, typeof(decimal))) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MinInclusive, facets.MinInclusive, (object)value); return(linqToXsdFacetException); } } if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.TotalDigits) != 0) { if (base.CheckTotalAndFractionDigits(value, Convert.ToInt32(facets.TotalDigits), 0, true, false) != null) { linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.TotalDigits, (object)facets.TotalDigits, (object)value); return(linqToXsdFacetException); } } linqToXsdFacetException = null; } else { linqToXsdFacetException = null; } return(linqToXsdFacetException); }