/// <summary> /// Parse an object from <paramref name="r"/> using the type hint <paramref name="t"/> /// </summary> /// <param name="r">The reader to read from</param> /// <param name="t">The type hint for the formatter</param> /// <returns>A structured result</returns> public IFormatterParseResult Parse(XmlReader r, Type t) { // Get the struct attribute IDatatypeFormatter formatter = null; Type cType = t; // Don't check for XSI type if the type is a GTS or iterable // This is because the XSI type on these classes will mislead the formatter selector if (t == typeof(GTS) || t.GetInterface(typeof(IEnumerable).FullName, false) != null && !t.IsAbstract) { formatter = GetFormatter(t); } else { // Force processing as an XSI:Type if (r.GetAttribute("type", NS_XSI) != null) { cType = Util.ParseXSITypeName(r.GetAttribute("type", NS_XSI)); } formatter = GetFormatter(cType); } if (formatter == null) { return(null); } // Set host and parse DatatypeFormatterParseResult result = new DatatypeFormatterParseResult(this.CompatibilityMode, ResultCode.Accepted, null, this.ValidateConformance); formatter.Host = (IXmlStructureFormatter)(this.Host ?? this); #if WINDOWS_PHONE bool hasErrors = s_unsupportedNames.Exists(o => (t.IsGenericType ? t.GetGenericTypeDefinition() : t).Equals(o)); #else bool hasErrors = Array.Exists(s_unsupportedNames, o => (t.IsGenericType ? t.GetGenericTypeDefinition() : t).Equals(o)); #endif // Errors if (hasErrors) { var structAtt = t.GetCustomAttributes(typeof(StructureAttribute), false); if (structAtt.Length > 0) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail( ResultDetailType.Warning, "All", (structAtt[0] as StructureAttribute).Name, r.ToString() )); } } // Structure graph result.Structure = formatter.Parse(r, result) as IGraphable; return(result); }
/// <summary> /// Parse an object from <paramref name="r"/> using the type hint <paramref name="t"/> /// </summary> /// <param name="r">The reader to read from</param> /// <param name="t">The type hint for the formatter</param> /// <returns>A structured result</returns> public IFormatterParseResult Parse(XmlReader r, Type t) { // Get the struct attribute IDatatypeFormatter formatter = null; Type cType = t; //if (formatter != null && t != typeof(GTS) && formatter.GenericArguments == null ) // formatter.GenericArguments = t.GetGenericArguments(); if (t == typeof(GTS) || t.GetInterface(typeof(IEnumerable).FullName) != null && !t.IsAbstract) { formatter = GetFormatter(t); } else { // Force processing as an XSI:Type if (r.GetAttribute("type", NS_XSI) != null) { cType = Util.ParseXSITypeName(r.GetAttribute("type", NS_XSI)); } formatter = GetFormatter(cType); } if (formatter == null) { return(null); } // Set host and parse DatatypeFormatterParseResult result = new DatatypeFormatterParseResult(this.CompatibilityMode, ResultCode.Accepted, null, this.ValidateConformance); formatter.Host = (IXmlStructureFormatter)(this.Host ?? this); // Errors if (Array.Exists(s_unsupportedNames, o => (t.IsGenericType ? t.GetGenericTypeDefinition() : t).Equals(o))) { var structAtt = t.GetCustomAttributes(typeof(StructureAttribute), false); if (structAtt.Length > 0) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail( ResultDetailType.Warning, "All", (structAtt[0] as StructureAttribute).Name, r.ToString() )); } } // Structure graph result.Structure = formatter.Parse(r, result) as IGraphable; return(result); }
/// <summary> /// Parse an object from <paramref name="r"/> using the type hint <paramref name="t"/> /// </summary> /// <param name="r">The reader to read from</param> /// <param name="t">The type hint for the formatter</param> /// <returns>A structured result</returns> public IFormatterParseResult Parse(XmlReader r, Type t) { // Get the struct attribute IDatatypeFormatter formatter = null; Type cType = t; // Don't check for XSI type if the type is a GTS or iterable // This is because the XSI type on these classes will mislead the formatter selector if (t == typeof(GTS) || t.GetInterface(typeof(IEnumerable).FullName, false) != null && !t.IsAbstract) formatter = GetFormatter(t); else { // Force processing as an XSI:Type if (r.GetAttribute("type", NS_XSI) != null) cType = Util.ParseXSITypeName(r.GetAttribute("type", NS_XSI)); formatter = GetFormatter(cType); } if (formatter == null) return null; // Set host and parse DatatypeFormatterParseResult result = new DatatypeFormatterParseResult(this.CompatibilityMode, ResultCode.Accepted, null, this.ValidateConformance); formatter.Host = (IXmlStructureFormatter)(this.Host ?? this); #if WINDOWS_PHONE bool hasErrors = s_unsupportedNames.Exists(o => (t.IsGenericType ? t.GetGenericTypeDefinition() : t).Equals(o)); #else bool hasErrors = Array.Exists(s_unsupportedNames, o => (t.IsGenericType ? t.GetGenericTypeDefinition() : t).Equals(o)); #endif // Errors if (hasErrors) { var structAtt = t.GetCustomAttributes(typeof(StructureAttribute), false); if (structAtt.Length > 0) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail( ResultDetailType.Warning, "All", (structAtt[0] as StructureAttribute).Name, r.ToString() )); } // Structure graph result.Structure = formatter.Parse(r, result) as IGraphable; return result; }
/// <summary> /// Parse an object from <paramref name="r"/> using the type hint <paramref name="t"/> /// </summary> /// <param name="r">The reader to read from</param> /// <param name="t">The type hint for the formatter</param> /// <returns>A structured result</returns> public IFormatterParseResult Parse(XmlReader r, Type t) { // Get the struct attribute IDatatypeFormatter formatter = null; Type cType = t; //if (formatter != null && t != typeof(GTS) && formatter.GenericArguments == null ) // formatter.GenericArguments = t.GetGenericArguments(); if (t == typeof(GTS) || t.GetInterface(typeof(IEnumerable).FullName) != null && !t.IsAbstract) formatter = GetFormatter(t); else { // Force processing as an XSI:Type if (r.GetAttribute("type", NS_XSI) != null) cType = Util.ParseXSITypeName(r.GetAttribute("type", NS_XSI)); formatter = GetFormatter(cType); } if (formatter == null) return null; // Set host and parse DatatypeFormatterParseResult result = new DatatypeFormatterParseResult(this.CompatibilityMode, ResultCode.Accepted, null, this.ValidateConformance); formatter.Host = (IXmlStructureFormatter)(this.Host ?? this); // Errors if (Array.Exists(s_unsupportedNames, o => (t.IsGenericType ? t.GetGenericTypeDefinition() : t).Equals(o))) { var structAtt = t.GetCustomAttributes(typeof(StructureAttribute), false); if (structAtt.Length > 0) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail( ResultDetailType.Warning, "All", (structAtt[0] as StructureAttribute).Name, r.ToString() )); } // Structure graph result.Structure = formatter.Parse(r, result) as IGraphable; return result; }