當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。