Parse() публичный Метод

public Parse ( System.Xml.Linq.XDocument getCapabilitiesXmlDocument ) : WfsServiceViewModel
getCapabilitiesXmlDocument System.Xml.Linq.XDocument
Результат WfsServiceViewModel
Пример #1
0
        public WfsServiceViewModel GetLayers(string wfsUrl)
        {
            if (!string.IsNullOrWhiteSpace(wfsUrl))
            {
                WfsServiceViewModel serviceModel = new WfsServiceViewModel();

                XDocument xmlDocument = XDocument.Load(wfsUrl);

                XElement root = xmlDocument.Element(WFS + "WFS_Capabilities");
                if (root != null)
                {
                    string version = root.Attribute("version").Value;
                    version = version.Substring(0, 3);

                    if (version == "1.0")
                    {
                        WfsGetCapabilities10Parser parser = new WfsGetCapabilities10Parser();
                        serviceModel = parser.Parse(xmlDocument);
                    }

                    else if (version == "1.1")
                    {
                        WfsGetCapabilities11Parser parser = new WfsGetCapabilities11Parser();
                        serviceModel = parser.Parse(xmlDocument);
                    }
                    else
                    {
                        WfsGetCapabilities11Parser parser = new WfsGetCapabilities11Parser();
                        serviceModel = parser.Parse(xmlDocument);
                    }
                }
                else
                {
                    XElement root2 = xmlDocument.Element(WFS2 + "WFS_Capabilities");
                    if (root2 != null)
                    {
                        WfsGetCapabilities20Parser parser = new WfsGetCapabilities20Parser();
                        serviceModel = parser.Parse(xmlDocument);
                    }
                    else
                    {
                        serviceModel = null;
                    }
                }

                return(serviceModel);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        public WfsServiceViewModel GetLayers(string wfsUrl)
        {
            if (!string.IsNullOrWhiteSpace(wfsUrl))
            {
                WfsServiceViewModel serviceModel = new WfsServiceViewModel();

                XDocument xmlDocument = XDocument.Load(wfsUrl);

                XElement root = xmlDocument.Element(WFS + "WFS_Capabilities");
                if (root != null)
                {
                    string version = root.Attribute("version").Value;
                    version = version.Substring(0, 3);

                    if (version == "1.0")
                    {
                    WfsGetCapabilities10Parser parser = new WfsGetCapabilities10Parser();
                    serviceModel = parser.Parse(xmlDocument);
                    }

                    else if (version == "1.1")
                    {
                    WfsGetCapabilities11Parser parser = new WfsGetCapabilities11Parser();
                    serviceModel = parser.Parse(xmlDocument);
                    }
                    else
                    {
                        WfsGetCapabilities11Parser parser = new WfsGetCapabilities11Parser();
                        serviceModel = parser.Parse(xmlDocument);
                    }

                }
                else
                {
                    XElement root2 = xmlDocument.Element(WFS2 + "WFS_Capabilities");
                    if (root2 != null)
                    {
                        WfsGetCapabilities20Parser parser = new WfsGetCapabilities20Parser();
                        serviceModel = parser.Parse(xmlDocument);
                    }
                    else
                        serviceModel = null;
                }

                return serviceModel;
            }
            else
                return null;
        }