/// <summary> /// Gets the object with the specified unique ID. /// </summary> public static bool TryGetObject(string key, out ProjectObject obj) { s_objectsLock.EnterReadLock(); try { return(s_objects.TryGetValue(key, out obj)); } finally { s_objectsLock.ExitReadLock(); } }
/// <summary> /// Adds a new object to the database. /// </summary> public static void AddObject(string uniqueId, ProjectObject obj) { Thread.Sleep(0); if (obj == null) { throw new ArgumentNullException("obj"); } s_objectsLock.EnterWriteLock(); try { s_objects[uniqueId] = obj; } finally { s_objectsLock.ExitWriteLock(); } Added?.Invoke(null, new ObjectDatabaseEventArgs(obj)); }
/// <summary> /// Adds a new object to the database if it doesn't already exist. /// </summary> public static void AddPlaceholderObject(string uniqueId, ProjectObject obj) { if (obj == null) { throw new ArgumentNullException("obj"); } s_objectsLock.EnterWriteLock(); try { if (!s_objects.ContainsKey(uniqueId)) { s_objects.Add(uniqueId, obj); } } finally { s_objectsLock.ExitWriteLock(); } Added?.Invoke(null, new ObjectDatabaseEventArgs(obj)); }
public ObjectDatabaseEventArgs(ProjectObject affectedObject) { Object = affectedObject; }