internal void Verify() { XmlConvert.VerifyNCName(name); if (ns.Length != 0) { XmlConvert.ToUri(ns); } }
private void CreateValidator(XmlSchemaObject partialValidationType, XmlSchemaValidationFlags validationFlags) { this.validator = new XmlSchemaValidator(this.nameTable, this.schemas, this.NamespaceResolver, validationFlags); this.validator.SourceUri = XmlConvert.ToUri(this.document.BaseURI); this.validator.XmlResolver = null; this.validator.ValidationEventHandler += this.internalEventHandler; this.validator.ValidationEventSender = this; if (partialValidationType != null) { this.validator.Initialize(partialValidationType); } else { this.validator.Initialize(); } }
private object ValueAs(string text, Type type, IXmlNamespaceResolver resolver, bool isArrayItem) { try { if (type == typeof(object)) { return(text); } if (type.IsArray && !isArrayItem) { var elemType = type.GetElementType(); var sarr = text.Split((string [])null, StringSplitOptions.RemoveEmptyEntries); var ret = Array.CreateInstance(elemType, sarr.Length); for (int i = 0; i < ret.Length; i++) { ret.SetValue(ValueAs(sarr [i], elemType, resolver, true), i); } return(ret); } if (type == typeof(XmlQualifiedName)) { if (resolver != null) { return(XmlQualifiedName.Parse(text, resolver, true)); } else { return(XmlQualifiedName.Parse(text, this, true)); } } if (type == typeof(Uri)) { return(XmlConvert.ToUri(text)); } if (type == typeof(TimeSpan)) { return(XmlConvert.ToTimeSpan(text)); } if (type == typeof(DateTimeOffset)) { return(XmlConvert.ToDateTimeOffset(text)); } switch (Type.GetTypeCode(type)) { case TypeCode.Boolean: return(XQueryConvert.StringToBoolean(text)); case TypeCode.DateTime: return(XQueryConvert.StringToDateTime(text)); case TypeCode.Decimal: return(XQueryConvert.StringToDecimal(text)); case TypeCode.Double: return(XQueryConvert.StringToDouble(text)); case TypeCode.Int32: return(XQueryConvert.StringToInt(text)); case TypeCode.Int64: return(XQueryConvert.StringToInteger(text)); case TypeCode.Single: return(XQueryConvert.StringToFloat(text)); case TypeCode.String: return(text); } } catch (Exception ex) { throw XmlError(String.Format("Current text value '{0}' is not acceptable for specified type '{1}'. {2}", text, type, ex != null ? ex.Message : String.Empty), ex); } throw new ArgumentException(String.Format("Specified type '{0}' is not supported.", type)); }