Beispiel #1
0
        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 bool Equals(object obj)
        {
            IndexedTemplateTypeReference other = obj as IndexedTemplateTypeReference;

            if (other == null)
            {
                return(false);
            }
            if ((this.index == other.index) && (this.templateId == other.templateId))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public IDictionary <IndexedTemplateTypeReference, TypeReference> GetSpecializationDictionary()
        {
            Dictionary <IndexedTemplateTypeReference, TypeReference> dictionary =
                new Dictionary <IndexedTemplateTypeReference, TypeReference>();

            foreach (Specialization specialization in specializations)
            {
                IList <TypeReference> arguments = specialization.arguments;
                for (int index = 0; index < arguments.Count; index++)
                {
                    IndexedTemplateTypeReference template =
                        new IndexedTemplateTypeReference(specialization.TemplateType.Id, index);
                    dictionary.Add(template, arguments[index]);
                }
            }

            return(dictionary);
        }