本文整理汇总了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);
}
}
}
示例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);
}
}
示例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();
}
}
}