本文整理汇总了C#中OpenSource.UPnP.UPnPStateVariable.GetAssociations方法的典型用法代码示例。如果您正苦于以下问题:C# UPnPStateVariable.GetAssociations方法的具体用法?C# UPnPStateVariable.GetAssociations怎么用?C# UPnPStateVariable.GetAssociations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSource.UPnP.UPnPStateVariable
的用法示例。
在下文中一共展示了UPnPStateVariable.GetAssociations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveStateVariable
/// <summary>
/// Remove a UPnPStateVariable
/// <para>
/// An exception will be thrown if you try to remove a UPnPStateVariable that is associated with an action,
/// or a UPnPStateVariable that is referenced by an Action.
/// </para>
/// </summary>
/// <param name="stateVariable">UPnPStateVariable to remove</param>
public void RemoveStateVariable(UPnPStateVariable stateVariable)
{
foreach (UPnPStateVariable.AssociationNode n in stateVariable.GetAssociations())
{
try
{
if (GetAction(n.ActionName).GetArg(n.ArgName).StateVarName == stateVariable.Name)
{
throw (new UPnPStateVariable.CannotRemoveException("Associated with " + n.ActionName + ":" + n.ArgName));
}
}
catch (System.NullReferenceException)
{ }
}
StateVariables.Remove(stateVariable.Name);
}
示例2: AddStateVariable
/// <summary>
/// Add a UPnPStateVariable
/// </summary>
/// <param name="NewVar"></param>
public void AddStateVariable(UPnPStateVariable NewVar)
{
NewVar.ParentService = this;
StateVariables[NewVar.Name] = NewVar;
UPnPStateVariable.AssociationNode[] Nodes;
Hashtable ArgTable;
Nodes = NewVar.GetAssociations();
for (int x = 0; x < Nodes.Length; ++x)
{
ArgTable = (Hashtable)VarAssociation[Nodes[x].ActionName];
if (ArgTable == null) ArgTable = new Hashtable();
if (ArgTable.ContainsKey(Nodes[x].ArgName) == true)
{
StateVariables.Remove(((UPnPStateVariable)ArgTable[Nodes[x].ArgName]).Name);
}
ArgTable[Nodes[x].ArgName] = NewVar;
VarAssociation[Nodes[x].ActionName] = ArgTable;
// THIS: Updated to throw meaningfull exception instead of null reference
UPnPAction A = GetAction(Nodes[x].ActionName);
if (A != null)
{
UPnPArgument Argument = A.GetArg(Nodes[x].ArgName);
if (Argument == null)
{
throw (new Exception(string.Format("There is no parameter named {0} for the {1}.{2} method.", Nodes[x].ArgName, ServiceInstance.GetType().ToString(), Nodes[x].ActionName)));
}
Argument.StateVarName = NewVar.Name;
}
// THIS: End update
}
}