private void WriteTemplateType(TemplateTypeReference template, DisplayOptions options, XmlWriter writer, Dictionary <IndexedTemplateTypeReference, TypeReference> dictionary) { // if we have the name, just write it NamedTemplateTypeReference namedTemplate = template as NamedTemplateTypeReference; if (namedTemplate != null) { writer.WriteString(namedTemplate.Name); return; } IndexedTemplateTypeReference indexedTemplate = template as IndexedTemplateTypeReference; if (indexedTemplate != null) { if (dictionary != null && dictionary.ContainsKey(indexedTemplate)) { WriteType(dictionary[indexedTemplate], options, writer); } else { writer.WriteString(GetTemplateName(indexedTemplate.TemplateId, indexedTemplate.Index)); } return; } TypeTemplateTypeReference typeTemplate = template as TypeTemplateTypeReference; if (typeTemplate != null) { 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("Unknown template type"); }
private void WriteTemplateType(TemplateTypeReference template, DisplayOptions options, XmlWriter writer, Dictionary<IndexedTemplateTypeReference, TypeReference> dictionary) { // if we have the name, just write it NamedTemplateTypeReference namedTemplate = template as NamedTemplateTypeReference; if(namedTemplate != null) { writer.WriteString(namedTemplate.Name); return; } IndexedTemplateTypeReference indexedTemplate = template as IndexedTemplateTypeReference; if(indexedTemplate != null) { if(dictionary != null && dictionary.ContainsKey(indexedTemplate)) WriteType(dictionary[indexedTemplate], options, writer); else writer.WriteString(GetTemplateName(indexedTemplate.TemplateId, indexedTemplate.Index)); return; } TypeTemplateTypeReference typeTemplate = template as TypeTemplateTypeReference; if(typeTemplate != null) { 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("Unknown template type"); }
/// <summary> /// This is overridden to allow comparison of to indexed template type references for equality /// </summary> /// <param name="obj">The instance to compare</param> /// <returns>True if equal, false if not</returns> public override bool Equals(object obj) { IndexedTemplateTypeReference other = obj as IndexedTemplateTypeReference; return(other != null && this.Index == other.Index && this.TemplateId == other.TemplateId); }