internal virtual Exception TryParseString(object value, NameTable nameTable, XNamespaceResolver resolver, out string parsedString) { throw new InvalidOperationException(); }
internal virtual Exception CheckLexicalFacets(ref string parsedString, object value, NameTable nameTable, XNamespaceResolver resolver, SimpleTypeValidator type) { RestrictionFacets facets = type.RestrictionFacets; if (facets == null || !facets.HasLexicalFacets) { return(null); } RestrictionFlags flags = facets.Flags; XmlSchemaWhiteSpace wsPattern = XmlSchemaWhiteSpace.Collapse; if ((flags & RestrictionFlags.WhiteSpace) != 0) { if (facets.WhiteSpace == XmlSchemaWhiteSpace.Collapse) { wsPattern = XmlSchemaWhiteSpace.Collapse; } else if (facets.WhiteSpace == XmlSchemaWhiteSpace.Preserve) { wsPattern = XmlSchemaWhiteSpace.Preserve; } } return(CheckLexicalFacets(ref parsedString, type, facets.Patterns, wsPattern)); }
internal override Exception TryParseValue(object value, NameTable nameTable, XNamespaceResolver resolver, out SimpleTypeValidator matchingType, out object typedValue) { Exception unionMemberTypeNotFoundException; typedValue = null; matchingType = null; if (value != null) { object typedMemberValue = null; SimpleTypeValidator[] simpleTypeValidatorArray = this.memberTypes; int num = 0; while (num < (int)simpleTypeValidatorArray.Length) { if (simpleTypeValidatorArray[num].TryParseValue(value, nameTable, resolver, out matchingType, out typedMemberValue) != null) { num++; } else { break; } } if (typedMemberValue != null) { Exception e = null; if ((base.RestrictionFacets == null ? false : base.RestrictionFacets.HasLexicalFacets)) { string parsedString = null; e = matchingType.TryParseString(value, nameTable, resolver, out parsedString); if (e == null) { e = this.facetsChecker.CheckLexicalFacets(ref parsedString, value, nameTable, resolver, this); } } if (e == null) { e = this.facetsChecker.CheckValueFacets(typedMemberValue, this); } if (e == null) { typedValue = typedMemberValue; unionMemberTypeNotFoundException = null; } else { unionMemberTypeNotFoundException = e; } } else { unionMemberTypeNotFoundException = new UnionMemberTypeNotFoundException(value, this); } } else { unionMemberTypeNotFoundException = new ArgumentNullException("Argument value should not be null."); } return(unionMemberTypeNotFoundException); }
internal virtual Exception TryParseValue(object value, NameTable nameTable, XNamespaceResolver resolver, out SimpleTypeValidator matchingType, out object typedValue) { throw new InvalidOperationException(); }
internal override Exception TryParseValue(object value, NameTable nameTable, XNamespaceResolver resolver, out SimpleTypeValidator matchingType, out object typedValue) { //Only accepts string and IEnumerable Exception e = null; typedValue = null; matchingType = null; if (RestrictionFacets != null && RestrictionFacets.HasLexicalFacets) { string parsedString = null; e = TryParseString(value, nameTable, resolver, out parsedString); if (e == null) { e = facetsChecker.CheckLexicalFacets(ref parsedString, value, nameTable, resolver, this); } } if (e == null) { e = facetsChecker.CheckValueFacets(value, this); } if (e != null) { return(e); } //Check item type level IList listItems = null; e = ToList(value, ref listItems); if (e != null) { return(e); } foreach (object listItem in listItems) { object typedItemValue = null; SimpleTypeValidator itemMatchingType = null; e = itemType.TryParseValue(listItem, nameTable, resolver, out itemMatchingType, out typedItemValue); if (e != null) { return(e); } } //Passed all the restriction checks typedValue = listItems; matchingType = this; return(null); }
internal override Exception TryParseValue(object value, NameTable nameTable, XNamespaceResolver resolver, out SimpleTypeValidator matchingType, out object typedValue) { typedValue = null; matchingType = null; if (value == null) { return(new ArgumentNullException("Argument value should not be null.")); } object typedMemberValue = null; foreach (SimpleTypeValidator memberType in memberTypes) { if (memberType.TryParseValue(value, nameTable, resolver, out matchingType, out typedMemberValue) == null) { break; } } if (typedMemberValue == null) { return(new UnionMemberTypeNotFoundException(value, this)); } else { Exception e = null; if (RestrictionFacets != null && RestrictionFacets.HasLexicalFacets) { string parsedString = null; e = matchingType.TryParseString(value, nameTable, resolver, out parsedString); if (e == null) { e = facetsChecker.CheckLexicalFacets(ref parsedString, value, nameTable, resolver, this); } } if (e == null) { e = facetsChecker.CheckValueFacets(typedMemberValue, this); } if (e != null) { return(e); } else { typedValue = typedMemberValue; return(null); } } }
internal override Exception TryParseValue(object value, NameTable nameTable, XNamespaceResolver resolver, out SimpleTypeValidator matchingType, out object typedValue) { Exception exception; Exception e = null; typedValue = null; matchingType = null; if ((base.RestrictionFacets == null ? false : base.RestrictionFacets.HasLexicalFacets)) { string parsedString = null; e = this.TryParseString(value, nameTable, resolver, out parsedString); if (e == null) { e = this.facetsChecker.CheckLexicalFacets(ref parsedString, value, nameTable, resolver, this); } } if (e == null) { e = this.facetsChecker.CheckValueFacets(value, this); } if (e == null) { IList listItems = null; e = ListSimpleTypeValidator.ToList(value, ref listItems); if (e == null) { foreach (object listItem in listItems) { object typedItemValue = null; SimpleTypeValidator itemMatchingType = null; e = this.itemType.TryParseValue(listItem, nameTable, resolver, out itemMatchingType, out typedItemValue); if (e != null) { exception = e; return(exception); } } typedValue = listItems; matchingType = this; exception = null; } else { exception = e; } } else { exception = e; } return(exception); }
private Exception TryMatchAtomicType(object value, NameTable nameTable, XNamespaceResolver resolver) { XmlSchemaDatatype datatype = DataType; XmlTypeCode typeCode = datatype.TypeCode; Exception exception = null; try { datatype.ChangeType(value, DataType.ValueType, resolver); } catch (Exception e) { exception = e; } return(exception); }
internal override Exception TryParseString(object value, NameTable nameTable, XNamespaceResolver resolver, out string parsedString) { parsedString = value as string; if (parsedString != null) { return(null); } IEnumerable list = value as IEnumerable; if (list == null) { return(new InvalidCastException()); } StringBuilder bldr = new StringBuilder(); foreach (object o in list) { // Separate values by single space character if (bldr.Length != 0) { bldr.Append(' '); } // Append string value of next item in the list string s = null; Exception ie = itemType.TryParseString(o, nameTable, resolver, out s); if (ie == null) { bldr.Append(s); } else { return(ie); } } parsedString = bldr.ToString(); return(null); }
internal override Exception TryParseString(object value, NameTable nameTable, XNamespaceResolver resolver, out string parsedString) { parsedString = value as string; if (parsedString == null) { try { parsedString = (string)DataType.ChangeType(value, XTypedServices.typeOfString); } catch (Exception e) { return(e); } } return(null); }
internal override Exception TryParseValue(object value, NameTable nameTable, XNamespaceResolver resolver, out SimpleTypeValidator matchingType, out object typedValue) { Exception e = TryMatchAtomicType(value, nameTable, resolver); matchingType = null; typedValue = null; if (e != null) { return(e); } try { if (RestrictionFacets != null && RestrictionFacets.HasLexicalFacets) { string parsedString = null; e = TryParseString(value, nameTable, resolver, out parsedString); if (e == null) { e = facetsChecker.CheckLexicalFacets(ref parsedString, value, nameTable, resolver, this); } } if (e == null) { e = facetsChecker.CheckValueFacets(value, this); } if (e == null) { matchingType = this; typedValue = DataType.ChangeType(value, this.DataType.ValueType); } return(e); } catch (Exception ee) { return(ee); } }
internal override Exception TryParseValue(object value, NameTable nameTable, XNamespaceResolver resolver, out SimpleTypeValidator matchingType, out object typedValue) { Exception exception; Exception e = this.TryMatchAtomicType(value, nameTable, resolver); matchingType = null; typedValue = null; if (e == null) { try { if ((base.RestrictionFacets == null ? false : base.RestrictionFacets.HasLexicalFacets)) { string parsedString = null; e = this.TryParseString(value, nameTable, resolver, out parsedString); if (e == null) { e = this.facetsChecker.CheckLexicalFacets(ref parsedString, value, nameTable, resolver, this); } } if (e == null) { e = this.facetsChecker.CheckValueFacets(value, this); } if (e == null) { matchingType = this; typedValue = base.DataType.ChangeType(value, base.DataType.ValueType); } exception = e; } catch (Exception exception1) { exception = exception1; } } else { exception = e; } return(exception); }
internal virtual Exception CheckLexicalFacets(ref string parsedString, object value, NameTable nameTable, XNamespaceResolver resolver, SimpleTypeValidator type) { RestrictionFacets facets = type.RestrictionFacets; if (facets == null || !facets.HasLexicalFacets) { return null; } RestrictionFlags flags = facets.Flags; XmlSchemaWhiteSpace wsPattern = XmlSchemaWhiteSpace.Collapse; if ((flags & RestrictionFlags.WhiteSpace) != 0) { if (facets.WhiteSpace == XmlSchemaWhiteSpace.Collapse) { wsPattern = XmlSchemaWhiteSpace.Collapse; } else if (facets.WhiteSpace == XmlSchemaWhiteSpace.Preserve) { wsPattern = XmlSchemaWhiteSpace.Preserve; } } return CheckLexicalFacets(ref parsedString, type, facets.Patterns, wsPattern); }
internal override Exception TryParseString(object value, NameTable nameTable, XNamespaceResolver resolver, out string parsedString) { Exception invalidCastException; parsedString = value as string; if (parsedString == null) { IEnumerable list = value as IEnumerable; if (list != null) { StringBuilder bldr = new StringBuilder(); foreach (object o in list) { if (bldr.Length != 0) { bldr.Append(' '); } string s = null; Exception ie = this.itemType.TryParseString(o, nameTable, resolver, out s); if (ie != null) { invalidCastException = ie; return(invalidCastException); } else { bldr.Append(s); } } parsedString = bldr.ToString(); invalidCastException = null; } else { invalidCastException = new InvalidCastException(); } } else { invalidCastException = null; } return(invalidCastException); }
internal override Exception TryParseValue(object value, NameTable nameTable, XNamespaceResolver resolver, out SimpleTypeValidator matchingType, out object typedValue) { Exception e = TryMatchAtomicType(value, nameTable, resolver); matchingType = null; typedValue = null; if (e != null) return e; try { if (RestrictionFacets != null && RestrictionFacets.HasLexicalFacets) { string parsedString = null; e = TryParseString(value, nameTable, resolver, out parsedString); if (e==null) e = facetsChecker.CheckLexicalFacets(ref parsedString, value, nameTable, resolver, this); } if (e == null) e = facetsChecker.CheckValueFacets(value, this); if (e == null) { matchingType = this; typedValue = DataType.ChangeType(value, this.DataType.ValueType); } return e; } catch(Exception ee) { return ee; } }
internal override Exception TryParseString(object value, NameTable nameTable, XNamespaceResolver resolver, out string parsedString) { parsedString = value as string; if (parsedString == null) { try { parsedString = (string)DataType.ChangeType(value, XTypedServices.typeOfString); } catch (Exception e) { return e; } } return null; }
private Exception TryMatchAtomicType(object value, NameTable nameTable, XNamespaceResolver resolver) { XmlSchemaDatatype datatype = DataType; XmlTypeCode typeCode = datatype.TypeCode; Exception exception = null; try { datatype.ChangeType(value, DataType.ValueType, resolver); } catch(Exception e) { exception = e; } return exception; }
internal override Exception TryParseValue(object value, NameTable nameTable, XNamespaceResolver resolver, out SimpleTypeValidator matchingType, out object typedValue) { //Only accepts string and IEnumerable Exception e = null; typedValue = null; matchingType = null; if (RestrictionFacets != null && RestrictionFacets.HasLexicalFacets) { string parsedString = null; e = TryParseString(value, nameTable, resolver, out parsedString); if (e == null) e = facetsChecker.CheckLexicalFacets(ref parsedString, value, nameTable, resolver, this); } if (e == null) e = facetsChecker.CheckValueFacets(value, this); if (e != null) return e; //Check item type level IList listItems = null; e = ToList(value, ref listItems); if (e!=null) return e; foreach (object listItem in listItems) { object typedItemValue = null; SimpleTypeValidator itemMatchingType = null; e = itemType.TryParseValue(listItem, nameTable, resolver, out itemMatchingType, out typedItemValue); if (e != null) return e; } //Passed all the restriction checks typedValue = listItems; matchingType = this; return null; }
internal override Exception TryParseString(object value, NameTable nameTable, XNamespaceResolver resolver, out string parsedString) { parsedString = value as string; if (parsedString != null) return null; IEnumerable list = value as IEnumerable; if (list == null) return new InvalidCastException(); StringBuilder bldr = new StringBuilder(); foreach (object o in list) { // Separate values by single space character if (bldr.Length != 0) bldr.Append(' '); // Append string value of next item in the list string s = null; Exception ie = itemType.TryParseString(o, nameTable, resolver, out s); if (ie == null) { bldr.Append(s); } else { return ie; } } parsedString = bldr.ToString(); return null; }
internal override Exception TryParseString(object value, NameTable nameTable, XNamespaceResolver resolver, out string parsedString) { Exception exception; parsedString = value as string; if (parsedString == null) { try { parsedString = (string)base.DataType.ChangeType(value, XTypedServices.typeOfString); } catch (Exception exception1) { exception = exception1; return(exception); } } exception = null; return(exception); }
internal override Exception TryParseValue(object value, NameTable nameTable, XNamespaceResolver resolver, out SimpleTypeValidator matchingType, out object typedValue) { typedValue = null; matchingType = null; if (value == null) return new ArgumentNullException("Argument value should not be null."); object typedMemberValue = null; foreach (SimpleTypeValidator memberType in memberTypes) { if (memberType.TryParseValue(value, nameTable, resolver, out matchingType, out typedMemberValue) == null) { break; } } if (typedMemberValue == null) { return new UnionMemberTypeNotFoundException(value, this); } else { Exception e = null; if (RestrictionFacets != null && RestrictionFacets.HasLexicalFacets) { string parsedString = null; e = matchingType.TryParseString(value, nameTable, resolver, out parsedString); if (e == null) e = facetsChecker.CheckLexicalFacets(ref parsedString, value, nameTable, resolver, this); } if (e == null) e = facetsChecker.CheckValueFacets(typedMemberValue, this); if (e != null) return e; else { typedValue = typedMemberValue; return null; } } }
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); }