public static bool IsIdInUse(string id, IIdentifiedObject obj, string group) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (group == null) { throw new ArgumentNullException(nameof(@group)); } HashSet <IIdentifiedObject> itemGroup = UniqueIDCache.GetGroupCollection(group); return(itemGroup.Any(t => t.ID == id && t != obj)); }
public static void RemoveItem(IIdentifiedObject item, string group) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (group == null) { throw new ArgumentNullException(nameof(@group)); } HashSet <IIdentifiedObject> itemGroup = UniqueIDCache.GetGroupCollection(group); if (itemGroup.Contains(item)) { itemGroup.Remove(item); } }
public static void AddItem(IIdentifiedObject item, string group) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (group == null) { throw new ArgumentNullException(nameof(@group)); } HashSet <IIdentifiedObject> itemGroup = UniqueIDCache.GetGroupCollection(group); if (itemGroup.Any(t => t.ID == item.ID)) { throw new ArgumentException(string.Format("The specified id '{0}' is already in use in group {1}", item.ID, group)); } else { itemGroup.Add(item); } }
public static bool CanChangeId(string group, IIdentifiedObject item, string newId) { HashSet <IIdentifiedObject> itemGroup = UniqueIDCache.GetGroupCollection(group); return(!itemGroup.Any(t => t.ID == newId && t != item)); }
public static void ClearIdCache(string group) { UniqueIDCache.GetGroupCollection(group).Clear(); }
public static bool HasObject(string group, IIdentifiedObject item) { return(UniqueIDCache.GetGroupCollection(group).Contains(item)); }