Exemple #1
0
        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, 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();
        }
Exemple #3
0
        /// <summary>
        /// Write out a type reference
        /// </summary>
        /// <param name="type">The type reference information</param>
        /// <param name="options">The link display options</param>
        /// <param name="writer">The write to which the information is written</param>
        /// <param name="dictionary">The template type dictionary</param>
        private void WriteType(TypeReference type, DisplayOptions options, XmlWriter writer, Dictionary <IndexedTemplateTypeReference, TypeReference> dictionary)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            SimpleTypeReference simple = type as SimpleTypeReference;

            if (simple != null)
            {
                WriteSimpleType(simple, options, writer);
                return;
            }

            SpecializedTypeReference specialized = type as SpecializedTypeReference;

            if (specialized != null)
            {
                WriteSpecializedType(specialized, options, writer);
                return;
            }

            ArrayTypeReference array = type as ArrayTypeReference;

            if (array != null)
            {
                WriteArrayType(array, options, writer, dictionary);
                return;
            }

            ReferenceTypeReference reference = type as ReferenceTypeReference;

            if (reference != null)
            {
                WriteReferenceType(reference, options, writer, dictionary);
                return;
            }

            PointerTypeReference pointer = type as PointerTypeReference;

            if (pointer != null)
            {
                WritePointerType(pointer, options, writer, dictionary);
                return;
            }

            TemplateTypeReference template = type as TemplateTypeReference;

            if (template != null)
            {
                WriteTemplateType(template, options, writer, dictionary);
                return;
            }

            throw new InvalidOperationException("Unknown type reference 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");
        }
 private void WriteTemplateType(TemplateTypeReference template, ReferenceLinkDisplayOptions options,
                                XmlWriter writer)
 {
     WriteTemplateType(template, options, writer, null);
 }
        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();
        }
 private void WriteTemplateType (TemplateTypeReference template, DisplayOptions options, XmlWriter writer) {
     WriteTemplateType(template, options, writer, null);
 }