本文整理汇总了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();
//.........这里部分代码省略.........
示例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")
//.........这里部分代码省略.........