/// <summary> /// Unregisters item and returns true if it was unregistered, false if it did not exist /// </summary> public bool Unregister(T item) { lock (m_Sync) { if (!m_Data.ContainsKey(item.Name)) { return(false); } var data = new RegistryDictionary <T>(m_Data); data.Remove(item.Name); JustUnregistered(item); m_Data = data; } return(true); }
/// <summary> /// Registers item and returns true if it was registered, false if this named instance already existed in the list /// </summary> public bool Register(T item) { lock (m_Sync) { if (m_Data.ContainsKey(item.Name)) { return(false); } var data = new RegistryDictionary <T>(m_CaseSensitive, m_Data); data.Add(item.Name, item); JustRegistered(item); m_Data = data; } return(true); }
/// <summary> /// Unregisters item by name and returns true if it was unregistered, false if it did not exist /// </summary> public bool Unregister(string name) { lock (m_Sync) { T item; if (!m_Data.TryGetValue(name, out item)) { return(false); } var data = new RegistryDictionary <T>(m_Data); data.Remove(name); JustUnregistered(item); m_Data = data; } return(true); }
/// <summary> /// Registers item and returns true if it was registered, false if this named instance already existed and was replaced /// </summary> public bool RegisterOrReplace(T item, out T existing) { lock (m_Sync) { var data = new RegistryDictionary <T>(m_Data); if (data.TryGetValue(item.Name, out existing)) { data[item.Name] = item; JustReplaced(existing, item); } else { existing = default(T);//safeguard data.Add(item.Name, item); JustRegistered(item); } m_Data = data; } return(existing == null); }
/// <summary> /// Deletes all items from registry /// </summary> public virtual void Clear() { m_Data = new RegistryDictionary <T>(); //atomic }
/// <summary> /// Deletes all items from registry /// </summary> public virtual void Clear() { m_Data = new RegistryDictionary <T>(m_CaseSensitive); //atomic }
public Registry(bool caseSensitive) { m_CaseSensitive = caseSensitive; m_Data = new RegistryDictionary <T>(caseSensitive); }