本文整理汇总了C#中OpenSource.UPnP.UPnPDevice.GetCustomFieldsFromDescription方法的典型用法代码示例。如果您正苦于以下问题:C# UPnPDevice.GetCustomFieldsFromDescription方法的具体用法?C# UPnPDevice.GetCustomFieldsFromDescription怎么用?C# UPnPDevice.GetCustomFieldsFromDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSource.UPnP.UPnPDevice
的用法示例。
在下文中一共展示了UPnPDevice.GetCustomFieldsFromDescription方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateAddDevice
private void GenerateAddDevice(CodeProcessor cs, UPnPDevice device)
{
string dev = gendevnumber.ToString();
if (gendevnumber == 0) dev = "";
if (device.ParentDevice == null)
{
cs.Append("device = UPnPDevice.CreateRootDevice(1800,1.0,\"\\\\\");"+cl);
}
else
{
cs.Append("UPnPDevice device"+dev+" = UPnPDevice.CreateEmbeddedDevice(1,System.Guid.NewGuid().ToString());"+cl);
}
//
// Add Custom Tags
//
foreach (string ns in device.GetCustomFieldFromDescription_Namespaces())
{
foreach (KeyValuePair<string, string> tag in device.GetCustomFieldsFromDescription(ns))
{
cs.Append("device" + dev + ".AddCustomFieldInDescription(\"" + tag.Key + "\", \"" + tag.Value + "\", \"" + ns + "\");" + cl);
}
}
cs.Append(cl);
cs.Append("device"+dev+".FriendlyName = \""+device.FriendlyName+"\";"+cl);
if (device.Manufacturer != null) cs.Append("device"+dev+".Manufacturer = \""+device.Manufacturer+"\";"+cl);
if (device.ManufacturerURL != null) cs.Append("device"+dev+".ManufacturerURL = \""+device.ManufacturerURL+"\";"+cl);
if (device.ModelName != null) cs.Append("device"+dev+".ModelName = \""+device.ModelName+"\";"+cl);
if (device.ModelDescription != null) cs.Append("device"+dev+".ModelDescription = \""+device.ModelDescription+"\";"+cl);
if (device.ModelURL != null) cs.Append("device"+dev+".ModelURL = new Uri(\""+device.ModelURL.ToString()+"\");"+cl);
if (device.ModelNumber != null) cs.Append("device"+dev+".ModelNumber = \""+device.ModelNumber+"\";"+cl);
cs.Append("device"+dev+".HasPresentation = false;"+cl);
cs.Append("device"+dev+".DeviceURN = \""+device.DeviceURN+"\";"+cl);
foreach (UPnPService service in device.Services)
{
string servicename = (string)ServiceNames[service];
cs.Append(nspace+".Dv" + servicename + " " + servicename + " = new "+nspace+".Dv" + servicename + "();" + cl);
//ConnectionManager.External_ConnectionComplete(new OpenSource.DeviceBuilder.ConnectionManager.Delegate_ConnectionComplete(ConnectionCompleteAction));
foreach (UPnPAction action in service.Actions)
{
cs.Append(servicename + ".External_" + action.Name + " = new "+nspace+".Dv" + servicename + ".Delegate_" + action.Name + "(" + servicename + "_" + action.Name + ");" + cl);
}
cs.Append("device"+dev+".AddService(" + servicename + ");" + cl);
}
gendevnumber++;
foreach (UPnPDevice embeddeddevice in device.EmbeddedDevices)
{
int dn = gendevnumber;
GenerateAddDevice(cs,embeddeddevice);
cs.Append("device"+dev+".AddDevice(device" + dn + ");" + cl);
gendevnumber++;
}
cs.Append(cl);
}
示例2: ProcessDevice_BuildService
private void ProcessDevice_BuildService(UPnPDevice device, CodeProcessor cs)
{
//
// Add Custom Tags
//
foreach (string ns in device.GetCustomFieldFromDescription_Namespaces())
{
foreach (KeyValuePair<string, string> tag in device.GetCustomFieldsFromDescription(ns))
{
cs.Append(" device.AddCustomTag(\"" + ns + "\", \"" + tag.Key + "\", \"" + tag.Value + "\");" + cl);
}
}
//
// Populate the rest of the Metadata
//
cs.Append(" device.Manufacturer = \"" + device.Manufacturer + "\";"+cl);
cs.Append(" device.ManufacturerURL = \"" + device.ManufacturerURL + "\";"+cl);
cs.Append(" device.ModelDescription = \"" + device.ModelDescription + "\";"+cl);
cs.Append(" device.ModelName = \"" + device.ModelName + "\";"+cl);
cs.Append(" device.ModelNumber = \"" + device.ModelNumber + "\";"+cl);
cs.Append(" device.ModelURL = \"" + device.ModelURL + "\";"+cl);
cs.Append(" device.SerialNumber = \"" + device.SerialNumber + "\";" + cl);
//
// Process Services/Devices
//
foreach (UPnPService service in device.Services)
{
string serviceName = (string)ServiceNames[service];
cs.Append(" service = new UPnPService(\"");
cs.Append(service.ServiceURN + "\", \"" + service.ServiceID + "\");" + cl);
foreach (UPnPStateVariable var in service.GetStateVariables())
{
cs.Append(" var = new UPnPStateVariable(\"" + var.Name + "\", \"" + var.ValueType + "\", " + (var.SendEvent ? "true" : "false") + ");" + cl);
//
// Populate Fields
//
if (var.AllowedStringValues != null)
{
bool isFirst = true;
StringBuilder asb = new StringBuilder();
foreach (string value in var.AllowedStringValues)
{
if (!isFirst)
{
asb.Append(", ");
}
else
{
isFirst = false;
}
asb.Append("\"" + value + "\"");
}
cs.Append(" var.SetAllowedValues(new String[]{" + asb.ToString() + "});" + cl);
}
if (var.Minimum != null || var.Maximum != null)
{
// Set Range
cs.Append(" var.SetRange(" + (var.Minimum != null ? ("\"" + var.Minimum.ToString() + "\"") : "null") + ", " + (var.Maximum != null ? ("\"" + var.Maximum.ToString() + "\"") : "null") + ", " + (var.Step != null ? ("\"" + var.Step.ToString() + "\"") : "null") + ");" + cl);
}
// Set Default Value
if (var.DefaultValue != null)
{
cs.Append(" var.SetDefaultValue(\"" + var.DefaultValue.ToString() + "\");" + cl);
}
cs.Append(" service.AddStateVariable(var);" + cl);
}
foreach (UPnPAction action in service.Actions)
{
cs.Append(cl);
cs.Append(" inParams.clear();" + cl);
foreach (UPnPArgument arg in action.Arguments)
{
cs.Append(" arg = new UPnPArgument(\"" + arg.Name + "\", ArgumentDirection.");
if (arg.IsReturnValue)
{
cs.Append("RETURN");
}
else
{
cs.Append(arg.Direction.ToUpper());
}
cs.Append(", service.getStateVariable(\"" + arg.RelatedStateVar.Name + "\"));" + cl);
cs.Append(" inParams.add(arg);" + cl);
}
cs.Append(" action = new UPnPAction(\"" + action.Name + "\", inParams, new " + serviceName + "_" + action.Name + "_Dispatcher());" + cl);
cs.Append(" service.AddAction(action);" + cl);
}
cs.Append(" device.AddService(service);" + cl);
}
cs.Append(" mDevice" + embeddedTable[device].ToString() + " = device;" + cl);
foreach (UPnPDevice eDevice in device.EmbeddedDevices)
{
//.........这里部分代码省略.........