public static TypeReference ReadTypeReference(XmlReader reader) { if (reader == null || reader.NodeType != XmlNodeType.Element) { return(null); } switch (reader.Name) { // For the TypeReference(s)... case "SimpleTypeReference": SimpleTypeReference simpleTypeReference = new SimpleTypeReference(); simpleTypeReference.ReadXml(reader); return(simpleTypeReference); case "SpecializedTypeReference": SpecializedTypeReference specializedTypeReference = new SpecializedTypeReference(); specializedTypeReference.ReadXml(reader); return(specializedTypeReference); case "ArrayTypeReference": ArrayTypeReference arrayTypeReference = new ArrayTypeReference(); arrayTypeReference.ReadXml(reader); return(arrayTypeReference); case "ReferenceTypeReference": ReferenceTypeReference referenceTypeReference = new ReferenceTypeReference(); referenceTypeReference.ReadXml(reader); return(referenceTypeReference); case "PointerTypeReference": PointerTypeReference pointerTypeReference = new PointerTypeReference(); pointerTypeReference.ReadXml(reader); return(pointerTypeReference); // For the TemplateTypeReference(s)... case "IndexedTemplateTypeReference": IndexedTemplateTypeReference indexedTemplateTypeReference = new IndexedTemplateTypeReference(); indexedTemplateTypeReference.ReadXml(reader); return(indexedTemplateTypeReference); case "NamedTemplateTypeReference": NamedTemplateTypeReference namedTemplateTypeReference = new NamedTemplateTypeReference(); namedTemplateTypeReference.ReadXml(reader); return(namedTemplateTypeReference); case "TypeTemplateTypeReference": TypeTemplateTypeReference typeTemplateTypeReference = new TypeTemplateTypeReference(); typeTemplateTypeReference.ReadXml(reader); return(typeTemplateTypeReference); case "MethodTemplateTypeReference": MethodTemplateTypeReference methodTemplateTypeReference = new MethodTemplateTypeReference(); methodTemplateTypeReference.ReadXml(reader); return(methodTemplateTypeReference); } return(null); }
public override void ReadXml(XmlReader reader) { if (reader == null) { return; } if (String.Equals(reader.Name, "TypeTemplateTypeReference", StringComparison.OrdinalIgnoreCase)) { string tempText = reader.GetAttribute("position"); if (!String.IsNullOrEmpty(tempText)) { position = Int32.Parse(tempText); } } if (reader.IsEmptyElement) { return; } XmlNodeType nodeType = XmlNodeType.None; while (reader.Read()) { nodeType = reader.NodeType; if (nodeType == XmlNodeType.Element) { if (String.Equals(reader.Name, "TypeTemplateTypeReference", StringComparison.OrdinalIgnoreCase)) { string tempText = reader.GetAttribute("position"); if (!String.IsNullOrEmpty(tempText)) { position = Int32.Parse(tempText); } } else if (String.Equals(reader.Name, "SimpleTypeReference", StringComparison.OrdinalIgnoreCase)) { template = new SimpleTypeReference(); template.ReadXml(reader); } } else if (nodeType == XmlNodeType.EndElement) { if (String.Equals(reader.Name, "TypeTemplateTypeReference", StringComparison.OrdinalIgnoreCase)) { break; } } } }
public void ReadXml(XmlReader reader) { if (reader == null || reader.IsEmptyElement) { return; } arguments = new List <TypeReference>(); XmlNodeType nodeType = XmlNodeType.None; while (reader.Read()) { nodeType = reader.NodeType; if (nodeType == XmlNodeType.Element) { if (String.Equals(reader.Name, "SimpleTypeReference", StringComparison.OrdinalIgnoreCase)) { template = new SimpleTypeReference(); template.ReadXml(reader); } else if (String.Equals(reader.Name, "Arguments", StringComparison.OrdinalIgnoreCase)) { while (reader.Read()) { nodeType = reader.NodeType; if (nodeType == XmlNodeType.Element) { if (reader.Name.EndsWith("TypeReference", StringComparison.OrdinalIgnoreCase)) { TypeReference typeRef = ReferencesReader.ReadTypeReference(reader); if (typeRef != null) { arguments.Add(typeRef); } } } else if (nodeType == XmlNodeType.EndElement) { if (String.Equals(reader.Name, "Arguments", StringComparison.OrdinalIgnoreCase)) { break; } } } } } else if (nodeType == XmlNodeType.EndElement) { if (String.Equals(reader.Name, "Specialization", StringComparison.OrdinalIgnoreCase)) { break; } } } }