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


C# UPnPDevice.AddCustomFieldInDescription方法代码示例

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


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

示例1: AddAllCustomFieldsToDevice

            public void AddAllCustomFieldsToDevice(UPnPDevice d)
            {
                IDictionaryEnumerator NamespaceEnumerator;
                IDictionaryEnumerator EntryEnumerator;

                d.ClearCustomFieldsInDescription();
                NamespaceEnumerator = CustomFieldTable.GetEnumerator();
                while (NamespaceEnumerator.MoveNext())
                {
                    EntryEnumerator = ((Hashtable)NamespaceEnumerator.Value).GetEnumerator();
                    while (EntryEnumerator.MoveNext())
                    {
                        d.AddCustomFieldInDescription((string)EntryEnumerator.Key, (string)EntryEnumerator.Value, (string)NamespaceEnumerator.Key);
                    }
                }
            }
开发者ID:Tieske,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:16,代码来源:ServiceGenerator.cs

示例2: ParseDevice


//.........这里部分代码省略.........
                                    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();
                            break;
                        case "serviceList":
                            if (XMLDoc.IsEmptyElement)
                                break;

                            XMLDoc.Read();
                            XMLDoc.MoveToContent();
                            while (XMLDoc.LocalName != "serviceList")
                            {
                                if (XMLDoc.LocalName == "service")
                                {
                                    embeddedLine = XMLDoc.LineNumber;
                                    service = UPnPService.Parse(XMLDoc.ReadOuterXml(), embeddedLine - 1 + startLine);
                                    RetVal.AddService(service);
                                }
                                if (!XMLDoc.IsStartElement())
                                {
                                    if (XMLDoc.LocalName != "serviceList")
                                    {
                                        XMLDoc.Read();
                                        XMLDoc.MoveToContent();
                                    }
                                }
                            }
                            break;

                        /*
                            case "iconList":
                                bool finishedIconList = false;
                                while (!finishedIconList && XMLDoc.Read())
                                {
                                    switch (XMLDoc.NodeType)
                                    {
                                        case XmlNodeType.Element:
                                            if (XMLDoc.LocalName == "icon")
                                            {
                                                embeddedLine = XMLDoc.LineNumber;
                                                ParseIconXML(RetVal, startLine + embeddedLine-1, XMLDoc.ReadOuterXml());
                                                if (XMLDoc.NodeType == XmlNodeType.EndElement && XMLDoc.LocalName == "iconList") { finishedIconList = true; }
                                            }
                                            break;
                                        case XmlNodeType.EndElement:
                                            if (XMLDoc.LocalName == "iconList") { finishedIconList = true; }
                                            break;
                                    }
                                }
                                break;
                            */

                        default:
                            if (XMLDoc.LocalName != "")
                            {
                                string customPrefix = XMLDoc.Prefix;
                                string customFieldName = XMLDoc.LocalName;
                                string customFieldNamespace = XMLDoc.LookupNamespace(customPrefix);
                                string customFieldVal = XMLDoc.ReadInnerXml();
                                RetVal.AddCustomFieldInDescription(customFieldName, customFieldVal, customFieldNamespace);
                            }
                            else
                            {
                                XMLDoc.Skip();
                            }
                            continue;
                        }

                        XMLDoc.Read();
                        //XMLDoc.MoveToContent();
                    }
                }
            }
            catch (XMLParsingException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new XMLParsingException("Invalid Device XML", startLine + XMLDoc.LineNumber, XMLDoc.LinePosition, ex);
            }
        }
开发者ID:genielabs,项目名称:intel-upnp-dlna,代码行数:101,代码来源:UPnPDevice.cs

示例3: ParseDevice


//.........这里部分代码省略.........
                            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")
                            {
                                if (XMLDoc.LocalName == "service")
                                {
                                    // TODO: DONE Resilience case 5a - wrap in try/catch block
                                    string servicexml = "Failed to read service xml element from device xml";
                                    try
                                    {
                                        servicexml = XMLDoc.ReadOuterXml();
                                        service = UPnPService.Parse(servicexml);
                                        RetVal.AddService(service);
                                    }
                                    catch (Exception e)
                                    {
                                        OpenSource.Utilities.EventLogger.Log(null, System.Diagnostics.EventLogEntryType.Error, "Invalid Service element within Device XML");
                                        OpenSource.Utilities.EventLogger.Log(e, "XML content: \r\n" + servicexml);
                                        OpenSource.Utilities.EventLogger.Log(null, System.Diagnostics.EventLogEntryType.Warning, "Dropping failed Service and commencing parsing remainder of device");
                                    }
                                }
                                if (!XMLDoc.IsStartElement())
                                {
                                    if (XMLDoc.LocalName != "serviceList")
                                    {
                                        XMLDoc.Read();
                                        XMLDoc.MoveToContent();
                                    }
                                }
                            }
                            break;
                        case "iconList":
                            bool finishedIconList = false;
                            while (!finishedIconList && XMLDoc.Read())
                            {
                                switch (XMLDoc.NodeType)
                                {
                                    case XmlNodeType.Element:
                                        if (XMLDoc.LocalName == "icon")
                                        {
                                            ParseIconXML(RetVal, XMLDoc.ReadOuterXml());
                                            if (XMLDoc.NodeType == XmlNodeType.EndElement && XMLDoc.LocalName == "iconList") { finishedIconList = true; }
                                        }
                                        break;
                                    case XmlNodeType.EndElement:
                                        if (XMLDoc.LocalName == "iconList") { finishedIconList = true; }
                                        break;
                                }
                            }
                            break;
                        default:
                            if (XMLDoc.LocalName != "")
                            {
                                string customPrefix = XMLDoc.Prefix;
                                string customFieldName = XMLDoc.LocalName;
                                string customFieldNamespace = XMLDoc.LookupNamespace(customPrefix);
                                string customFieldVal = XMLDoc.ReadInnerXml();
                                RetVal.AddCustomFieldInDescription(customFieldName, customFieldVal, customFieldNamespace);
                            }
                            else
                            {
                                XMLDoc.Skip();
                            }
                            continue;
                    }

                    XMLDoc.Read();
                    //XMLDoc.MoveToContent();
                }
            }
        }
开发者ID:Tieske,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:101,代码来源:UPnPDevice.cs


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