示例#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);
        }
示例#2
0
        public SpecializedMemberReference(SimpleMemberReference member, SpecializedTypeReference type)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            this.member = member;
            this.type   = type;
        }
        public SpecializedMemberWithParametersReference(string prefix, SpecializedTypeReference type,
                                                        string member, IList <TypeReference> parameters)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            this.prefix     = prefix;
            this.type       = type;
            this.member     = member;
            this.parameters = parameters;
        }
示例#4
0
        public override void ReadXml(XmlReader reader)
        {
            if (reader == null || reader.IsEmptyElement)
            {
                return;
            }

            XmlNodeType nodeType = XmlNodeType.None;

            while (reader.Read())
            {
                nodeType = reader.NodeType;

                if (nodeType == XmlNodeType.Element)
                {
                    if (String.Equals(reader.Name, "SimpleMemberReference",
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        member = new SimpleMemberReference();
                        member.ReadXml(reader);
                    }
                    else if (String.Equals(reader.Name, "SpecializedTypeReference",
                                           StringComparison.OrdinalIgnoreCase))
                    {
                        type = new SpecializedTypeReference();
                        type.ReadXml(reader);
                    }
                }
                else if (nodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, "SpecializedMemberReference",
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }
        public override void ReadXml(XmlReader reader)
        {
            if (reader == null)
            {
                return;
            }

            if (String.Equals(reader.Name, "SpecializedMemberWithParametersReference",
                              StringComparison.OrdinalIgnoreCase))
            {
                prefix = reader.GetAttribute("prefix");
                member = reader.GetAttribute("member");
            }

            if (reader.IsEmptyElement)
            {
                return;
            }

            parameters = new List <TypeReference>();

            XmlNodeType nodeType = XmlNodeType.None;

            while (reader.Read())
            {
                nodeType = reader.NodeType;

                if (nodeType == XmlNodeType.Element)
                {
                    if (String.Equals(reader.Name, "SpecializedMemberWithParametersReference",
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        prefix = reader.GetAttribute("prefix");
                        member = reader.GetAttribute("member");
                    }
                    else if (String.Equals(reader.Name, "SpecializedTypeReference",
                                           StringComparison.OrdinalIgnoreCase))
                    {
                        type = new SpecializedTypeReference();
                        type.ReadXml(reader);
                    }
                    else if (String.Equals(reader.Name, "Parameters",
                                           StringComparison.OrdinalIgnoreCase))
                    {
                        while (reader.Read())
                        {
                            nodeType = reader.NodeType;

                            if (nodeType == XmlNodeType.Element)
                            {
                                if (reader.Name.EndsWith("TypeReference",
                                                         StringComparison.OrdinalIgnoreCase))
                                {
                                    TypeReference typeRef = ReferencesReader.ReadTypeReference(reader);
                                    if (typeRef != null)
                                    {
                                        parameters.Add(typeRef);
                                    }
                                }
                            }
                            else if (nodeType == XmlNodeType.EndElement)
                            {
                                if (String.Equals(reader.Name, "Parameters",
                                                  StringComparison.OrdinalIgnoreCase))
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
                else if (nodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, "SpecializedMemberWithParametersReference",
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }