| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- using System;
- using Abp.Localization;
- namespace Abp.Configuration
- {
- /// <summary>
- /// Defines a setting.
- /// A setting is used to configure and change behavior of the application.
- /// </summary>
- public class SettingDefinition
- {
- /// <summary>
- /// Unique name of the setting.
- /// </summary>
- public string Name { get; private set; }
- /// <summary>
- /// Display name of the setting.
- /// This can be used to show setting to the user.
- /// </summary>
- public ILocalizableString DisplayName { get; set; }
- /// <summary>
- /// A brief description for this setting.
- /// </summary>
- public ILocalizableString Description { get; set; }
- /// <summary>
- /// Scopes of this setting.
- /// Default value: <see cref="SettingScopes.Application"/>.
- /// </summary>
- public SettingScopes Scopes { get; set; }
- /// <summary>
- /// Is this setting inherited from parent scopes.
- /// Default: True.
- /// </summary>
- public bool IsInherited { get; set; }
- /// <summary>
- /// Gets/sets group for this setting.
- /// </summary>
- public SettingDefinitionGroup Group { get; set; }
- /// <summary>
- /// Default value of the setting.
- /// </summary>
- public string DefaultValue { get; set; }
- /// <summary>
- /// Can clients see this setting and it's value.
- /// It maybe dangerous for some settings to be visible to clients (such as email server password).
- /// Default: false.
- /// </summary>
- [Obsolete("Use ClientVisibilityProvider instead.")]
- public bool IsVisibleToClients { get; set; }
- /// <summary>
- /// Client visibility definition for the setting.
- /// </summary>
- public ISettingClientVisibilityProvider ClientVisibilityProvider { get; set; }
- /// <summary>
- /// Can be used to store a custom object related to this setting.
- /// </summary>
- public object CustomData { get; set; }
- /// <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">Can clients see this setting and it's value. 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,
- ILocalizableString displayName = null,
- SettingDefinitionGroup group = null,
- ILocalizableString description = null,
- SettingScopes scopes = SettingScopes.Application,
- bool isVisibleToClients = false,
- bool isInherited = true,
- object customData = null,
- ISettingClientVisibilityProvider clientVisibilityProvider = null)
- {
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException(nameof(name));
- }
- Name = name;
- DefaultValue = defaultValue;
- DisplayName = displayName;
- Group = @group;
- Description = description;
- Scopes = scopes;
- IsVisibleToClients = isVisibleToClients;
- IsInherited = isInherited;
- CustomData = customData;
- ClientVisibilityProvider = new HiddenSettingClientVisibilityProvider();
- if (isVisibleToClients)
- {
- ClientVisibilityProvider = new VisibleSettingClientVisibilityProvider();
- }
- else if (clientVisibilityProvider != null)
- {
- ClientVisibilityProvider = clientVisibilityProvider;
- }
- }
- }
- }
|