Skip to content

DbSettingsAttribute class

namespace: Serenity.ComponentModel   assembly: Serenity.Net.Core

Marks an options class whose properties can be changed at runtime, e.g. on a settings page, with the changed values kept in the database. The class must also have a DefaultSectionKeyAttribute with a section key under SectionPrefix, e.g. "DbSettings:Site", as a value from the database is only ever provided under that section. A property can provide its value for another configuration key as well, with an OverlayConfigAttribute.

[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public class DbSettingsAttribute : Attribute, IImplicitLocalTextRegistrar, 
    IPropertyItemsTextPrefixProvider

Public Members

name description
DbSettingsAttribute() The default constructor.
AddLocalTexts(…) Adds the display name and the description of the class as the texts of its title and its description, as a group of settings has no form to have them.
GetPropertyItemsTextPrefix(…) Gets the prefix of the local text keys of the settings of a class: Forms., its section key with dots, and a dot, e.g. Forms.DbSettings.Site.. Null when the class has no section key.
const GroupDescriptionTextSuffix What follows the local text prefix of a class in the key of its description, "GroupDescription".
const GroupTitleTextSuffix What follows the local text prefix of a class in the key of its title, "GroupTitle".
const Section The configuration section that all the settings from the database are under, "DbSettings".
const SectionPrefix The prefix that the section key of a class with this attribute must start with, "DbSettings:".

Remarks

The public read/write properties of simple types (texts, numbers, booleans, enumerations, dates) of the class are the settings. A property with an IgnoreAttribute is not one, and a read-only one is shown but not changed. The permission attributes work as on a row: the read and modify permissions of the class are needed for any of its settings, a property can ask for one more, and the field read and modify permissions of the class are the defaults of the properties that have none.

The texts of the attributes of the class are translated like the ones of a form whose key is the section key: the display name of a property of "DbSettings:Site" has the local text key Forms.DbSettings.Site.PropertyName, its hint Forms.DbSettings.Site.PropertyName_Hint, and the display name and the description of the class Forms.DbSettings.Site.GroupTitle and Forms.DbSettings.Site.GroupDescription.

See Also