Пример #1
0
        /// <summary>
        /// Returns an array of the hierarchy of <see cref="ConfigRegister"/>s.
        /// </summary>
        /// <param name="highestToLowest">Whether to order the returned array from highest <see cref="ConfigRegister"/> in the hierarchy to the lowest.</param>
        public ConfigRegister[] GetConfigRegisterHierarchy(bool highestToLowest = true)
        {
            List <ConfigRegister> configRegisterHierarchy = new List <ConfigRegister>();

            ConfigRegister configRegister = this;

            while (configRegister != null && !configRegisterHierarchy.Contains(configRegister))
            {
                configRegisterHierarchy.Add(configRegister);

                // If there's another InheritableConfigRegister as a parent, then get the parent of that, otherwise, break the loop as there are no more parents
                if (configRegister is InheritableConfigRegister inheritableConfigRegister)
                {
                    configRegister = inheritableConfigRegister.ParentConfigRegister;
                }
                else
                {
                    break;
                }
            }

            if (highestToLowest)
            {
                configRegisterHierarchy.Reverse();
            }

            return(configRegisterHierarchy.ToArray());
        }
Пример #2
0
 /// <summary>
 /// Creates an <see cref="InheritableConfigRegister"/> with the parent <paramref name="parentConfigRegister"/> to inherit unset config values from.
 /// </summary>
 /// <param name="parentConfigRegister">The <see cref="ConfigRegister"/> to inherit unset config values from.</param>
 protected InheritableConfigRegister(ConfigRegister parentConfigRegister = null)
 {
     ParentConfigRegister = parentConfigRegister;
 }