Пример #1
0
        /// <summary>
        /// convert metadata file to MetadataSection (to feed code/proxy generator)
        ///  We don't reuse the buffered object model, because the generator could modify & corrupt them.
        /// </summary>
        /// <remarks></remarks>
        internal MetadataSection CreateMetadataSection()
        {
            MetadataContent metadata = LoadMetadataContent(m_MetadataType);
            if (metadata.MetadataFormatError != null)
            {
                throw metadata.MetadataFormatError;
            }

            MetadataSection metadataSection = null;

            switch (FileType)
            {
                case MetadataType.Unknown:
                    break;
                case MetadataType.Disco:
                    if (metadata.MetadataServiceDescription != null)
                    {
                        metadataSection = MetadataSection.CreateFromServiceDescription(metadata.MetadataServiceDescription);
                    }
                    break;
                case MetadataType.Wsdl:
                    // We need to make a copy of the WSDL object model since the act of importing it actuall
                    // modifies it, and we don't want the cached instance to be polluted...
                    System.Web.Services.Description.ServiceDescription description = metadata.MetadataServiceDescription;
                    if (description != null)
                    {
                        metadataSection = MetadataSection.CreateFromServiceDescription(description);
                    }
                    break;
                case MetadataType.Schema:
                    if (metadata.MetadataXmlSchema != null)
                    {
                        metadataSection = MetadataSection.CreateFromSchema(metadata.MetadataXmlSchema);
                    }
                    break;
                case MetadataFile.MetadataType.Policy:
                    if (metadata.MetadataXmlDocument != null)
                    {
                        metadataSection = MetadataSection.CreateFromPolicy(metadata.MetadataXmlDocument.DocumentElement, null);
                    }
                    break;
                case MetadataFile.MetadataType.Xml:
                case MetadataFile.MetadataType.Edmx:
                    if (metadata.MetadataXmlDocument != null)
                    {
                        metadataSection = new MetadataSection(null, null, metadata.MetadataXmlDocument.DocumentElement);
                    }
                    break;
                default:
                    System.Diagnostics.Debug.Fail("Unknown Type?");
                    break;
            }
            return metadataSection;
        }
        /// <summary>
        /// convert metadata file to MetadataSection (to feed code/proxy generator)
        ///  We don't reuse the buffered object model, because the generator could modify & corrupt them.
        /// </summary>
        /// <remarks></remarks>
        internal MetadataSection CreateMetadataSection()
        {
            MetadataContent metadata = LoadMetadataContent(m_MetadataType);

            if (metadata.MetadataFormatError != null)
            {
                throw metadata.MetadataFormatError;
            }

            MetadataSection metadataSection = null;

            switch (FileType)
            {
            case MetadataType.Unknown:
                break;

            case MetadataType.Disco:
                if (metadata.MetadataServiceDescription != null)
                {
                    metadataSection = MetadataSection.CreateFromServiceDescription(metadata.MetadataServiceDescription);
                }
                break;

            case MetadataType.Wsdl:
                // We need to make a copy of the WSDL object model since the act of importing it actuall
                // modifies it, and we don't want the cached instance to be polluted...
                System.Web.Services.Description.ServiceDescription description = metadata.MetadataServiceDescription;
                if (description != null)
                {
                    metadataSection = MetadataSection.CreateFromServiceDescription(description);
                }
                break;

            case MetadataType.Schema:
                if (metadata.MetadataXmlSchema != null)
                {
                    metadataSection = MetadataSection.CreateFromSchema(metadata.MetadataXmlSchema);
                }
                break;

            case MetadataFile.MetadataType.Policy:
                if (metadata.MetadataXmlDocument != null)
                {
                    metadataSection = MetadataSection.CreateFromPolicy(metadata.MetadataXmlDocument.DocumentElement, null);
                }
                break;

            case MetadataFile.MetadataType.Xml:
            case MetadataFile.MetadataType.Edmx:
                if (metadata.MetadataXmlDocument != null)
                {
                    metadataSection = new MetadataSection(null, null, metadata.MetadataXmlDocument.DocumentElement);
                }
                break;

            default:
                System.Diagnostics.Debug.Fail("Unknown Type?");
                break;
            }
            return(metadataSection);
        }
		public System.ServiceModel.Description.MetadataSection ReadObject_MetadataSection (bool isNullable, bool checkType)
		{
			System.ServiceModel.Description.MetadataSection ob = null;
			if (isNullable && ReadNull()) return null;

			if (checkType) 
			{
				System.Xml.XmlQualifiedName t = GetXsiType();
				if (t == null)
				{ }
				else if (t.Name != "MetadataSection" || t.Namespace != "http://schemas.xmlsoap.org/ws/2004/09/mex")
					throw CreateUnknownTypeException(t);
			}

			ob = new System.ServiceModel.Description.MetadataSection ();

			Reader.MoveToElement();

			int anyAttributeIndex = 0;
			System.Collections.ObjectModel.Collection<System.Xml.XmlAttribute> anyAttributeArray = null;
			while (Reader.MoveToNextAttribute())
			{
				if (Reader.LocalName == "Dialect" && Reader.NamespaceURI == "") {
					ob.@Dialect = Reader.Value;
				}
				else if (Reader.LocalName == "Identifier" && Reader.NamespaceURI == "") {
					ob.@Identifier = Reader.Value;
				}
				else if (IsXmlnsAttribute (Reader.LocalName)) {
				}
				else {
					System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute) Document.ReadNode(Reader);
					if (((object)anyAttributeArray) == null)
						anyAttributeArray = new System.Collections.ObjectModel.Collection<System.Xml.XmlAttribute>();
					anyAttributeArray.Add (((System.Xml.XmlAttribute) attr));
					anyAttributeIndex++;
				}
			}

			Reader.MoveToElement();
			if (Reader.IsEmptyElement) {
				Reader.Skip ();
				return ob;
			}

			Reader.ReadStartElement();
			Reader.MoveToContent();

			bool b0=false;

			while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
			{
				if (Reader.NodeType == System.Xml.XmlNodeType.Element) 
				{
					if (Reader.LocalName == "schema" && Reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema" && !b0) {
						b0 = true;
						ob.@Metadata = ReadObject_XmlSchema (false, true);
					}
					else if (Reader.LocalName == "Metadata" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/09/mex" && !b0) {
						b0 = true;
						ob.@Metadata = ((System.ServiceModel.Description.MetadataSet) ReadSerializable (new System.ServiceModel.Description.MetadataSet ()));
					}
					else if (Reader.LocalName == "Location" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/09/mex" && !b0) {
						b0 = true;
						ob.@Metadata = ReadObject_MetadataLocation (false, true);
					}
					else if (Reader.LocalName == "MetadataReference" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/09/mex" && !b0) {
						b0 = true;
						ob.@Metadata = ((System.ServiceModel.Description.MetadataReference) ReadSerializable (new System.ServiceModel.Description.MetadataReference ()));
					}
					else if (Reader.LocalName == "definitions" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/" && !b0) {
						b0 = true;
						ob.@Metadata = ReadObject_ServiceDescription (false, true);
					}
					else {
						UnknownNode (ob);
					}
				}
				else
					UnknownNode(ob);

				Reader.MoveToContent();
			}

			ReadEndElement();

			return ob;
		}