示例#1
0
        /// <summary>
        /// Removes an link (but not the item) from the address space only if it has no children.
        /// </summary>
        public bool RemoveEmptyLink(string browsePath)
        {
            lock (this)
            {
                // validate browse path.
                if (browsePath == null || browsePath.Length == 0)
                {
                    return(false);
                }

                // create the browse element.
                BrowseElement element = m_addressSpace.Find(browsePath);

                if (element != null)
                {
                    if (element.Count == 0)
                    {
                        element.Remove();
                        return(true);
                    }
                }

                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// Removes an link and an item with the same id to the address space.
        /// </summary>
        public bool RemoveItemAndLink(string browsePath)
        {
            lock (this)
            {
                // validate browse path.
                if (browsePath == null || browsePath.Length == 0)
                {
                    return(false);
                }

                // find the browse element.
                BrowseElement element = m_addressSpace.Find(browsePath);

                if (element != null)
                {
                    // remove item.
                    m_items.Remove(element.ItemID);

                    // remove element.
                    element.Remove();
                }

                return(true);
            }
        }