public Dictionary<IndexedTemplateTypeReference, TypeReference> GetSpecializationDictionary () { Dictionary<IndexedTemplateTypeReference, TypeReference> dictionary = new Dictionary<IndexedTemplateTypeReference, TypeReference>(); foreach (Specialization specialization in specializations) { for (int index=0; index<specialization.Arguments.Length; index++) { IndexedTemplateTypeReference template = new IndexedTemplateTypeReference(specialization.TemplateType.Id, index); dictionary.Add(template, specialization.Arguments[index]); } } return (dictionary); }
private void WriteTemplateType (TemplateTypeReference template, DisplayOptions options, XmlWriter writer, Dictionary<IndexedTemplateTypeReference, TypeReference> dictionary) { /* Console.WriteLine("template type {0}", template.GetType().FullName); if (dictionary != null) { foreach (IndexedTemplateTypeReference it in dictionary.Keys) { Console.WriteLine("index = {0}, api = {1} ({3}) -> {2}", it.Index, it.TemplateId, dictionary[it].GetType().FullName, it.GetHashCode()); } } */ // 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) { //Console.WriteLine("index = {0}, api = {1} ({2})", indexedTemplate.Index, indexedTemplate.TemplateId, indexedTemplate.GetHashCode()); //if ((dictionary != null) && (!dictionary.ContainsKey(indexedTemplate))) Console.WriteLine("not in dictionary"); if ((dictionary != null) && (dictionary.ContainsKey(indexedTemplate))) { //Console.WriteLine("Substituted {0}", dictionary[indexedTemplate].GetType().FullName); WriteType(dictionary[indexedTemplate], options, writer); } else { //Console.WriteLine("Getting name for id='{0}' and index={1}", indexedTemplate.TemplateId, indexedTemplate.Index); 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(); }