/// <summary> /// Removes an link (but not the item) from the address space only if it has no children. /// </summary> private 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); } }
// /// <summary> // /// Adds an link with an item id to the address space. // /// </summary> // private bool AddItemAndLink(string browsePath, string itemID, IDevice device) // { // lock (this) // { // // validate browse path. // if (browsePath == null || browsePath.Length == 0) // { // return false; // } // // // check if item does not exists. // //MPTD removed ! check it // if (m_items.Contains(itemID)) // { // return false; // } // // // create the browse element. // BrowseElement element = m_addressSpace.Insert(browsePath, itemID); // // if (element == null) // { // return false; // } // // // create new item and index by item id. // m_items[element.ItemID] = new CacheItem(itemID, device); // return true; // } // } /// <summary> /// Removes an link and an item with the same id to the address space. /// </summary> private 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); } }