Пример #1
0
 public static UpnpServiceInfo FromXmlServiceNode(XElement aServiceNode, Uri aDocUri, IHttpFetcher aFetcher)
 {
     var instance = new UpnpServiceInfo();
     foreach (var item in aServiceNode.Elements())
     {
         if (item.Name == UpnpDeviceXml.ServiceTypeElement) { instance.ServiceType = item.Value; }
         if (item.Name == UpnpDeviceXml.ServiceIdElement) { instance.ServiceId = item.Value; }
         if (item.Name == UpnpDeviceXml.SCPDURLElement)
         {
             instance.SCPDURL = item.Value;
             Uri absoluteUri;
             if (Uri.TryCreate(aDocUri, instance.SCPDURL, out absoluteUri))
             {
                 instance.DescriptionXml = aFetcher.SynchronousGetRequest(absoluteUri);
                 var descriptionDoc = XDocument.Parse(instance.DescriptionXml);
                 instance.Description = UpnpServiceDescriptionInfo.FromXmlScpdNode(descriptionDoc.Root);
             }
         }
         if (item.Name == UpnpDeviceXml.ControlURLElement) { instance.ControlURL = item.Value; }
         if (item.Name == UpnpDeviceXml.EventSubURLElement) { instance.EventSubURL = item.Value; }
     }
     return instance;
 }
Пример #2
0
        public static UpnpServiceInfo FromXmlServiceNode(XElement aServiceNode, Uri aDocUri, IHttpFetcher aFetcher)
        {
            var instance = new UpnpServiceInfo();

            foreach (var item in aServiceNode.Elements())
            {
                if (item.Name == UpnpDeviceXml.ServiceTypeElement)
                {
                    instance.ServiceType = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ServiceIdElement)
                {
                    instance.ServiceId = item.Value;
                }
                if (item.Name == UpnpDeviceXml.SCPDURLElement)
                {
                    instance.SCPDURL = item.Value;
                    Uri absoluteUri;
                    if (Uri.TryCreate(aDocUri, instance.SCPDURL, out absoluteUri))
                    {
                        instance.DescriptionXml = aFetcher.SynchronousGetRequest(absoluteUri);
                        var descriptionDoc = XDocument.Parse(instance.DescriptionXml);
                        instance.Description = UpnpServiceDescriptionInfo.FromXmlScpdNode(descriptionDoc.Root);
                    }
                }
                if (item.Name == UpnpDeviceXml.ControlURLElement)
                {
                    instance.ControlURL = item.Value;
                }
                if (item.Name == UpnpDeviceXml.EventSubURLElement)
                {
                    instance.EventSubURL = item.Value;
                }
            }
            return(instance);
        }
Пример #3
0
        public static UpnpDeviceInfo FromXmlDeviceNode(XElement aDeviceNode, Uri aDocUri, IHttpFetcher aFetcher)
        {
            var instance = new UpnpDeviceInfo();
            List <UpnpDeviceInfo>  embeddedDevices = new List <UpnpDeviceInfo>();
            List <UpnpServiceInfo> services        = new List <UpnpServiceInfo>();

            instance.EmbeddedDevices = embeddedDevices;
            instance.Services        = services;
            foreach (var item in aDeviceNode.Elements())
            {
                if (item.Name == UpnpDeviceXml.DeviceTypeElement)
                {
                    instance.DeviceType = item.Value;
                }
                if (item.Name == UpnpDeviceXml.FriendlyNameElement)
                {
                    instance.FriendlyName = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ManufacturerElement)
                {
                    instance.Manufacturer = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ManufacturerURLElement)
                {
                    instance.ManufacturerURL = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ModelDescriptionElement)
                {
                    instance.ModelDescription = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ModelNameElement)
                {
                    instance.ModelName = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ModelNumberElement)
                {
                    instance.ModelNumber = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ModelURLElement)
                {
                    instance.ModelURL = item.Value;
                }
                if (item.Name == UpnpDeviceXml.SerialNumberElement)
                {
                    instance.SerialNumber = item.Value;
                }
                if (item.Name == UpnpDeviceXml.UDNElement)
                {
                    instance.UDN = item.Value;
                }
                if (item.Name == UpnpDeviceXml.UPCElement)
                {
                    instance.UPC = item.Value;
                }
                if (item.Name == UpnpDeviceXml.DeviceListElement)
                {
                    foreach (var embeddedDeviceNode in item.Elements(UpnpDeviceXml.DeviceElement))
                    {
                        embeddedDevices.Add(UpnpDeviceInfo.FromXmlDeviceNode(embeddedDeviceNode, aDocUri, aFetcher));
                    }
                }
                if (item.Name == UpnpDeviceXml.ServiceListElement)
                {
                    foreach (var serviceNode in item.Elements(UpnpDeviceXml.ServiceElement))
                    {
                        services.Add(UpnpServiceInfo.FromXmlServiceNode(serviceNode, aDocUri, aFetcher));
                    }
                }
            }
            instance.BaseURI = aDocUri;
            return(instance);
        }