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); }
private void WriteTemplateType(TemplateTypeReference template, ReferenceLinkDisplayOptions options, XmlWriter writer, IDictionary <IndexedTemplateTypeReference, TypeReference> dictionary) { switch (template.ReferenceType) { case ReferenceType.NamedTemplate: // if we have the name, just write it NamedTemplateTypeReference namedTemplate = (NamedTemplateTypeReference)template; writer.WriteString(namedTemplate.Name); return; case ReferenceType.IndexedTemplate: IndexedTemplateTypeReference indexedTemplate = (IndexedTemplateTypeReference)template; if ((dictionary != null) && (dictionary.ContainsKey(indexedTemplate))) { WriteType(dictionary[indexedTemplate], options, writer); } else { writer.WriteString(GetTemplateName(indexedTemplate.TemplateId, indexedTemplate.Index)); } return; case ReferenceType.TypeTemplate: TypeTemplateTypeReference typeTemplate = (TypeTemplateTypeReference)template; TypeReference value = null; if (dictionary != null) { IndexedTemplateTypeReference key = new IndexedTemplateTypeReference( typeTemplate.TemplateType.Id, typeTemplate.Position); if (dictionary.ContainsKey(key)) { value = dictionary[key]; } } if (value == null) { writer.WriteString(GetTypeTemplateName(typeTemplate.TemplateType, typeTemplate.Position)); } else { WriteType(value, options, writer); } return; } throw new InvalidOperationException(); }
internal static void WriteSimpleMemberReference(SimpleMemberReference member, ReferenceLinkDisplayOptions options, XmlWriter writer, ReferenceLinkTextResolver resolver) { string cer = member.Id; string typeCer, memberName, arguments; DecomposeMemberIdentifier(cer, out typeCer, out memberName, out arguments); if ((options & ReferenceLinkDisplayOptions.ShowContainer) > 0) { SimpleTypeReference type = CreateSimpleTypeReference(typeCer); WriteSimpleTypeReference(type, options & ~ReferenceLinkDisplayOptions.ShowContainer, writer); } // change this so that we deal with EII names correctly, too writer.WriteString(memberName); if ((options & ReferenceLinkDisplayOptions.ShowParameters) > 0) { if (String.IsNullOrEmpty(arguments)) { Parameter[] parameters = new Parameter[0]; resolver.WriteMethodParameters(parameters, writer); } else { IList <string> parameterTypeCers = SeparateTypes(arguments); Parameter[] parameters = new Parameter[parameterTypeCers.Count]; for (int i = 0; i < parameterTypeCers.Count; i++) { TypeReference parameterType = CreateTypeReference(parameterTypeCers[i]); if (parameterType == null) { parameterType = new NamedTemplateTypeReference("UAT"); } parameters[i] = new Parameter(String.Empty, parameterType); } resolver.WriteMethodParameters(parameters, writer); } } }