using System; using System.Collections.Generic; using System.Collections.Immutable; using Abp.Localization; namespace Abp.Configuration { /// /// A setting group is used to group some settings togehter. /// A group can be child of another group and can have child groups. /// public class SettingDefinitionGroup { /// /// Unique name of the setting group. /// public string Name { get; private set; } /// /// Display name of the setting. /// This can be used to show setting to the user. /// public ILocalizableString DisplayName { get; private set; } /// /// Gets parent of this group. /// public SettingDefinitionGroup Parent { get; private set; } /// /// Gets a list of all children of this group. /// public IReadOnlyList Children { get { return _children.ToImmutableList(); } } private readonly List _children; /// /// Creates a new object. /// /// Unique name of the setting group /// Display name of the setting public SettingDefinitionGroup(string name, ILocalizableString displayName) { Check.NotNullOrWhiteSpace(name, nameof(name)); Name = name; DisplayName = displayName; _children = new List(); } /// /// Adds a as child of this group. /// /// Child to be added /// This child group to be able to add more child public SettingDefinitionGroup AddChild(SettingDefinitionGroup child) { if (child.Parent != null) { throw new AbpException("Setting group " + child.Name + " has already a Parent (" + child.Parent.Name + ")."); } _children.Add(child); child.Parent = this; return this; } } }