Creating Settings Objects
  • Updated on 09 Dec 2013
  • 1 minute to read
  • Print
  • Dark
    Light

Creating Settings Objects

  • Print
  • Dark
    Light

Overview

If your application requires its own set of settings, you can create new settings via code. After creating these settings, the values of these settings can be fetched and set via code (see Accessing System Settings (user settings) ) or by users who navigate in the portal to System > Settings and edit your specific settings.

Example of Creating Your Own Settings

Create a new class file project with a public class that inherits from and implementsAbstractModuleSettings . Add references toSystem.Runtime.Serialization and DecisionsFramework . D ecorate your class with [ORMEntity] & [DataContract] .

Below is an example implementation of AbstractModuleSettings .

 List<baseactiontype> actionTypes = new List<baseactiontype>();
actionTypes.Add(new EditEntityAction(typeof(MyCustomSettings), "Edit Settings", "Edit My Custom Settings"));
return actionTypes.ToArray();</baseactiontype></baseactiontype>

For each individual setting you want to be part of your new settings object, add a public and private member decorated as shown below.

 [ORMField]
private string externalUrl = "";

[DataMember]
public string ExternalUrl
{
    get { return externalUrl; }
    set { externalUrl = value; }
}

Your custom settings object will not be initialized until it is accessed for the first time.  If you want it intialized immediately, your type should implement IInitializable .

 public class DefaultAuditSettings : AbstractModuleSettings, IInitializable
....
public void Initialize()
{
   // Make sure Audit Settings gets initialized in life.
   ModuleSettingsAccessor<defaultauditsettings>.GetSettings();
}</defaultauditsettings>
Was this article helpful?