当前位置: 首页>>代码示例>>C#>>正文


C# UPnPDevice.SetVersion方法代码示例

本文整理汇总了C#中OpenSource.UPnP.UPnPDevice.SetVersion方法的典型用法代码示例。如果您正苦于以下问题:C# UPnPDevice.SetVersion方法的具体用法?C# UPnPDevice.SetVersion怎么用?C# UPnPDevice.SetVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenSource.UPnP.UPnPDevice的用法示例。


在下文中一共展示了UPnPDevice.SetVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseDevice

        private static void ParseDevice(String XML, int startLine, ref UPnPDevice RetVal)
        {
            string TempString;
            UPnPService service;
            int embeddedLine;
            DText p = new DText();
            TextReader MyString = new StringReader(XML);
            XmlTextReader XMLDoc = new XmlTextReader(MyString);

            try
            {
                XMLDoc.Read();
                XMLDoc.MoveToContent();

                if (XMLDoc.LocalName == "device")
                {
                    if (XMLDoc.AttributeCount > 0)
                    {
                        for (int ax = 0; ax < XMLDoc.AttributeCount; ++ax)
                        {
                            XMLDoc.MoveToAttribute(ax);
                            if (XMLDoc.LocalName == "MaxVersion")
                            {
                                RetVal.SetVersion(XMLDoc.Value);
                            }
                        }
                        XMLDoc.MoveToContent();
                        XMLDoc.Read();
                    }
                    else
                    {
                        XMLDoc.Read();
                        XMLDoc.MoveToContent();
                    }

                    while (XMLDoc.LocalName != "device" && !XMLDoc.EOF)
                    {
                        switch (XMLDoc.LocalName)
                        {
                        case "deviceList":
                            embeddedLine = XMLDoc.LineNumber;
                            ParseDeviceList(XMLDoc.ReadOuterXml(), startLine + embeddedLine - 1, ref RetVal);
                            break;
                        case "URLBase":
                                // Here, tport is a hack to make Windows Home Server visible. WHS does no set the port in the BaseURL and so, you need to keep it from the SSDP message.
                            int tport = 80;
                            if (RetVal.BaseURL != null)
                                tport = RetVal.BaseURL.Port;
                            RetVal.BaseURL = new Uri(XMLDoc.ReadString());
                            if (RetVal.BaseURL.Port == 80 && RetVal.BaseURL.Port != tport)
                                RetVal.BaseURL = new Uri(RetVal.BaseURL.Scheme + "://" + RetVal.BaseURL.Host + ":" + tport + RetVal.BaseURL.AbsolutePath);
                            break;
                        case "deviceType":
                            RetVal.DeviceURN = XMLDoc.ReadString();
                            break;
                        case "friendlyName":
                            RetVal.FriendlyName = XMLDoc.ReadString();
                            break;
                        case "manufacturer":
                            RetVal.Manufacturer = XMLDoc.ReadString();
                            break;
                        case "manufacturerURL":
                            RetVal.ManufacturerURL = XMLDoc.ReadString();
                            break;
                        case "modelDescription":
                            RetVal.ModelDescription = XMLDoc.ReadString();
                            break;
                        case "modelName":
                            RetVal.ModelName = XMLDoc.ReadString();
                            break;
                        case "modelNumber":
                            RetVal.ModelNumber = XMLDoc.ReadString();
                            break;
                        case "modelURL":
                            try
                            {
                                string u = XMLDoc.ReadString();
                                if (Uri.TryCreate(u, UriKind.Absolute, out RetVal.ModelURL) == false)
                                {
                                    Uri.TryCreate("http://" + u, UriKind.Absolute, out RetVal.ModelURL);
                                }
                            }
                            catch (Exception ex)
                            {
                                OpenSource.Utilities.EventLogger.Log(ex);
                            }
                            break;
                        case "serialNumber":
                            RetVal.SerialNumber = XMLDoc.ReadString();
                            break;
                        case "UDN":
                            TempString = XMLDoc.ReadString();
                            RetVal.UniqueDeviceName = TempString.Substring(5);
                            break;
                        case "UPC":
                            RetVal.ProductCode = XMLDoc.ReadString();
                            break;
                        case "presentationURL":
                            RetVal.HasPresentation = true;
                            RetVal.PresentationURL = XMLDoc.ReadString();
//.........这里部分代码省略.........
开发者ID:genielabs,项目名称:intel-upnp-dlna,代码行数:101,代码来源:UPnPDevice.cs

示例2: ParseDevice

        /// <summary>
        /// Parses an xml to a UPnP device (either a root or an embedded device)
        /// </summary>
        /// <param name="XML">xml containing the device description</param>
        /// <param name="RetVal">the UPnP device into which the xml data will be parsed</param>
        private static void ParseDevice(String XML, ref UPnPDevice RetVal)
        {
            string TempString;
            UPnPService service;
            DText p = new DText();
            TextReader MyString = new StringReader(XML);
            XmlTextReader XMLDoc = new XmlTextReader(MyString);

            XMLDoc.Read();
            XMLDoc.MoveToContent();

            if (XMLDoc.LocalName == "device")
            {
                if (XMLDoc.AttributeCount > 0)
                {
                    for (int ax = 0; ax < XMLDoc.AttributeCount; ++ax)
                    {
                        XMLDoc.MoveToAttribute(ax);
                        if (XMLDoc.LocalName == "MaxVersion")
                        {
                            RetVal.SetVersion(XMLDoc.Value);
                        }
                    }
                    XMLDoc.MoveToContent();
                    XMLDoc.Read();
                }
                else
                {
                    XMLDoc.Read();
                    XMLDoc.MoveToContent();
                }

                while (XMLDoc.LocalName != "device" && !XMLDoc.EOF)
                {
                    switch (XMLDoc.LocalName)
                    {
                        case "deviceList":
                            ParseDeviceList(XMLDoc.ReadOuterXml(), ref RetVal);
                            break;
                        case "URLBase":
                            // Here, tport is a hack to make Windows Home Server visible. WHS does no set the port in the BaseURL and so, you need to keep it from the SSDP message.
                            int tport = 80;
                            if (RetVal.BaseURL != null) tport = RetVal.BaseURL.Port;
                            RetVal.BaseURL = new Uri(XMLDoc.ReadString());
                            if (RetVal.BaseURL.Port == 80 && RetVal.BaseURL.Port != tport) RetVal.BaseURL = new Uri(RetVal.BaseURL.Scheme + "://" + RetVal.BaseURL.Host + ":" + tport + RetVal.BaseURL.AbsolutePath);
                            break;
                        case "deviceType":
                            RetVal.DeviceURN = XMLDoc.ReadString();
                            break;
                        case "friendlyName":
                            RetVal.FriendlyName = XMLDoc.ReadString();
                            break;
                        case "manufacturer":
                            RetVal.Manufacturer = XMLDoc.ReadString();
                            break;
                        case "manufacturerURL":
                            RetVal.ManufacturerURL = XMLDoc.ReadString();
                            break;
                        case "modelDescription":
                            RetVal.ModelDescription = XMLDoc.ReadString();
                            break;
                        case "modelName":
                            RetVal.ModelName = XMLDoc.ReadString();
                            break;
                        case "modelNumber":
                            RetVal.ModelNumber = XMLDoc.ReadString();
                            break;
                        case "modelURL":
                            try
                            {
                                string u = XMLDoc.ReadString();
                                if (Uri.TryCreate(u, UriKind.Absolute, out RetVal.ModelURL) == false) { Uri.TryCreate("http://" + u, UriKind.Absolute, out RetVal.ModelURL); }
                            }
                            catch { }
                            break;
                        case "serialNumber":
                            RetVal.SerialNumber = XMLDoc.ReadString();
                            break;
                        case "UDN":
                            TempString = XMLDoc.ReadString();
                            RetVal.UniqueDeviceName = TempString.Substring(5);
                            break;
                        case "UPC":
                            RetVal.ProductCode = XMLDoc.ReadString();
                            break;
                        case "presentationURL":
                            RetVal.HasPresentation = true;
                            RetVal.PresentationURL = XMLDoc.ReadString();
                            break;
                        case "serviceList":
                            if (XMLDoc.IsEmptyElement) break;

                            XMLDoc.Read();
                            XMLDoc.MoveToContent();
                            while (XMLDoc.LocalName != "serviceList")
//.........这里部分代码省略.........
开发者ID:Tieske,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:101,代码来源:UPnPDevice.cs


注:本文中的OpenSource.UPnP.UPnPDevice.SetVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。