using System;
using Abp.Localization;
namespace Abp.Configuration
{
///
/// Defines a setting.
/// A setting is used to configure and change behavior of the application.
///
public class SettingDefinition
{
///
/// Unique name of the setting.
///
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; set; }
///
/// A brief description for this setting.
///
public ILocalizableString Description { get; set; }
///
/// Scopes of this setting.
/// Default value: .
///
public SettingScopes Scopes { get; set; }
///
/// Is this setting inherited from parent scopes.
/// Default: True.
///
public bool IsInherited { get; set; }
///
/// Gets/sets group for this setting.
///
public SettingDefinitionGroup Group { get; set; }
///
/// Default value of the setting.
///
public string DefaultValue { get; set; }
///
/// 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.
///
[Obsolete("Use ClientVisibilityProvider instead.")]
public bool IsVisibleToClients { get; set; }
///
/// Client visibility definition for the setting.
///
public ISettingClientVisibilityProvider ClientVisibilityProvider { get; set; }
///
/// Can be used to store a custom object related to this setting.
///
public object CustomData { get; set; }
///
/// Creates a new object.
///
/// Unique name of the setting
/// Default value of the setting
/// Display name of the permission
/// Group of this setting
/// A brief description for this setting
/// Scopes of this setting. Default value: .
/// Can clients see this setting and it's value. Default: false
/// Is this setting inherited from parent scopes. Default: True.
/// Can be used to store a custom object related to this setting
/// Client visibility definition for the setting. Default: invisible
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;
}
}
}
}