예제 #1
0
        /// <summary>
        /// Creates a new <see cref="SettingDefinition"/> object.
        /// </summary>
        /// <param name="name">Unique name of the setting</param>
        /// <param name="defaultValue">Default value of the setting</param>
        /// <param name="displayName">Display name of the permission</param>
        /// <param name="group">Group of this setting</param>
        /// <param name="description">A brief description for this setting</param>
        /// <param name="scopes">Scopes of this setting. Default value: <see cref="SettingScopes.Application"/>.</param>
        /// <param name="isVisibleToClients">This parameter is obsolete. Use <paramref name="clientVisibilityProvider"/> instead! Default: false</param>
        /// <param name="isInherited">Is this setting inherited from parent scopes. Default: True.</param>
        /// <param name="customData">Can be used to store a custom object related to this setting</param>
        /// <param name="clientVisibilityProvider">Client visibility definition for the setting. Default: invisible</param>
        public SettingDefinition(
            string name,
            string defaultValue,
            string displayName           = null,
            SettingDefinitionGroup group = null,
            string description           = null,
            SettingScopes scopes         = SettingScopes.Application,
            bool isVisibleToClients      = false,
            bool isInherited             = true,
            JsonDocument customData      = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            Name         = name;
            DefaultValue = defaultValue;
            DisplayName  = displayName;
            Group        = @group;
            Description  = description;
            Scopes       = scopes;
            IsInherited  = isInherited;
            CustomData   = customData;
        }
        /// <summary>
        /// Adds a <see cref="SettingDefinitionGroup"/> as child of this group.
        /// </summary>
        /// <param name="child">Child to be added</param>
        /// <returns>This child group to be able to add more child</returns>
        public SettingDefinitionGroup AddChild(SettingDefinitionGroup child)
        {
            if (child.Parent != null)
            {
                throw new Exception("Setting group " + child.Name + " has already a Parent (" + child.Parent.Name + ").");
            }

            _children.Add(child);
            child.Parent = this;
            return(this);
        }