当前位置: 首页>>代码示例>>C#>>正文


C# UPnPStateVariable.GetAssociations方法代码示例

本文整理汇总了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);
        }
开发者ID:rvodden,项目名称:upnp-developertools-old,代码行数:26,代码来源:UPnPService.cs

示例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
            }
        }
开发者ID:rvodden,项目名称:upnp-developertools-old,代码行数:40,代码来源:UPnPService.cs


注:本文中的OpenSource.UPnP.UPnPStateVariable.GetAssociations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。