public static void ClearObjects()
        {
            var objectControllers = GetObjectsInLocation();

            var withOutParent = new List <ObjectController>();

            foreach (ObjectController objectController in objectControllers)
            {
                if (objectController.Parent != null)
                {
                    continue;
                }

                withOutParent.Add(objectController);
            }

            foreach (ObjectController o in withOutParent)
            {
                o.Delete();
            }

            ObjectsIds.Clear();
            ObjectsCollectionChanged?.Invoke();
            LogManager.GetCurrentClassLogger().Info($"Location objects was deleted");
        }
        public static void Dispose(this ObjectController self)
        {
            if (ObjectsIds.ContainsKey(self))
            {
                ObjectsIds.Remove(self);
                ObjectsCollectionChanged?.Invoke();
            }

            if (ObjectTypeEntities.ContainsKey(self.Id))
            {
                ObjectTypeEntities.Remove(self.Id);
            }

            GC.Collect();
        }
        public static int SetIdInLocation(this ObjectController self, int id)
        {
            if (!ObjectsIds.ContainsKey(self))
            {
                ObjectsIds.Add(self, id);
                ObjectsCollectionChanged?.Invoke();
            }

            if (!ObjectTypeEntities.ContainsKey(id))
            {
                ObjectTypeEntities.Add(id, self.Entity);
            }
            else
            {
                ObjectTypeEntities[id] = self.Entity;
            }

            return(ObjectsIds[self]);
        }
        public static void RegisterMeInLocation(this ObjectController self, ref int instanceId)
        {
            if (instanceId == 0)
            {
                int newId;

                if (ObjectsIds.Count == 0)
                {
                    newId = 1;
                }
                else
                {
                    newId = ObjectsIds.Values.ToList().Max() + 1;
                }

                instanceId = newId;
                self.SetName(instanceId.ToString());
            }

            ObjectsIds.Add(self, instanceId);
            ObjectTypeEntities.Add(instanceId, self.Entity);
            ObjectsCollectionChanged?.Invoke();
        }