Exemple #1
0
        /// <summary>
        ///     Renames a loaded Hierarchy by instance.
        /// </summary>
        /// <param name="hierarchyObject">The HierarchyObject in LoadedHierarchies to rename.</param>
        /// <param name="newName">The new name to use.</param>
        public static void SetHierarchyName(HierarchyObject hierarchyObject, string newName)
        {
            HierarchiesChanged?.Invoke();

            var key = GetHierarchyName(hierarchyObject);

            LoadedHierarchies.Remove(key);

            LoadedHierarchies.Add(newName, hierarchyObject);
        }
Exemple #2
0
        /// <summary>
        ///     Renames a loaded Hierarchy by key.
        /// </summary>
        /// <param name="currentName">The current name of the Hierarchy.</param>
        /// <param name="newName">The new name of the Hierarchy.</param>
        public static void SetHierarchyName(string currentName, string newName)
        {
            HierarchiesChanged?.Invoke();

            HierarchyObject hierarchy = LoadedHierarchies[currentName];

            LoadedHierarchies.Remove(currentName);

            LoadedHierarchies.Add(newName, hierarchy);
        }
Exemple #3
0
        /// <summary>
        ///     Get the key (name) of a Hierarchy in LoadedHierarchies.
        /// </summary>
        /// <param name="hierarchyObject">The Hierarchy to find the name of.</param>
        /// <returns>The name of the HierarchyObject.</returns>
        public static string GetHierarchyName(HierarchyObject hierarchyObject)
        {
            if (!LoadedHierarchies.ContainsValue(hierarchyObject))
            {
                throw new KeyNotFoundException("Hierarchy not found!");
            }

            string key;

            key = LoadedHierarchies.First(x => ReferenceEquals(x.Value, hierarchyObject)).Key;

            return(key);
        }
Exemple #4
0
        /// <summary>
        ///     Adds a Hierarchy to the loaded Hierarchies. Use LoadHierarchy() unless the Hierarchy is constructed at runtime.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="hierarchyObject"></param>
        public static void AddHierarchy(string name, HierarchyObject hierarchyObject)
        {
            LoadedHierarchies.Add(name, hierarchyObject);

            HierarchiesChanged?.Invoke();
        }