Exemple #1
0
        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));
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
        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));
        }
Exemple #5
0
 public static void ClearIdCache(string group)
 {
     UniqueIDCache.GetGroupCollection(group).Clear();
 }
Exemple #6
0
 public static bool HasObject(string group, IIdentifiedObject item)
 {
     return(UniqueIDCache.GetGroupCollection(group).Contains(item));
 }