Class PlugInSettings
Class for handling simple plugin settings as a DataSet
Inheritance
Namespace: EPiServer.PlugIn
Assembly: EPiServer.dll
Version: 12.0.3Syntax
public class PlugInSettings : Object
Remarks
Use this class if you wish to store simple relational data and web.config or database is not an option.
Examples
The TestSettings method below demonstrates how a plug-in could load and save some internal settings.
public void TestSettings()
{
DataSet ds = Load();
DataRow row = ds.Tables[0].NewRow();
row["String"] = "The value";
ds.Tables[0].Rows.Add(row);
Save(ds);
}
private void Save(DataSet ds)
{
PlugInSettings.Save(GetType(), ds);
}
private DataSet Load()
{
DataSet ds = new DataSet();
ds.Tables.Add(new DataTable());
ds.Tables[0].Columns.Add(new DataColumn("String", typeof(string)));
PlugInSettings.Populate(GetType(), ds);
return ds;
}
Methods
AutoPopulate(Object)
Called to populate the a PlugIn's properties with user supplied values from the database.
Declaration
public static void AutoPopulate(object obj)
Parameters
Type | Name | Description |
---|---|---|
System. |
obj | The instance of the PlugIn to populate |
ChangeType(Object, Type)
This member supports the EPiServer infrastructure and is not intended to be used directly from your code.
Declaration
public static object ChangeType(object value, Type destinationType)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The value. |
System. |
destinationType | Type of the destination. |
Returns
Type | Description |
---|---|
System. |
The converted object. |
GetProperties(Type)
Gets the editable properties for the indicated plug-in type.
Declaration
public static Dictionary<PropertyInfo, PlugInPropertyAttribute> GetProperties(Type type)
Parameters
Type | Name | Description |
---|---|---|
System. |
type | The plug-in type. |
Returns
Type | Description |
---|---|
System. |
A Dictionary with the plugin properties. |
Populate(PlugInDescriptor, DataSet)
Populates the settings for the specified plug-in descriptor.
Declaration
public static void Populate(PlugInDescriptor descr, DataSet settings)
Parameters
Type | Name | Description |
---|---|---|
Plug |
descr | The descriptor. |
System. |
settings | The settings DataSet to use. |
Remarks
This method simply PlugInDescriptor without further manipulation.
Populate(Type, DataSet)
Populate dataset with data for plugin
Declaration
public static void Populate(Type type, DataSet settings)
Parameters
Type | Name | Description |
---|---|---|
System. |
type | The type of plugin |
System. |
settings | The dataset with settings to populate |
Save(PlugInDescriptor, DataSet)
Saves the specified plug-in descriptor settings.
Declaration
public static void Save(PlugInDescriptor descr, DataSet settings)
Parameters
Type | Name | Description |
---|---|---|
Plug |
descr | The plug-in descriptor. |
System. |
settings | The settings. |
Save(Type, DataSet)
Save dataset with settings to database
Declaration
public static void Save(Type type, DataSet settings)
Parameters
Type | Name | Description |
---|---|---|
System. |
type | The type of plugin |
System. |
settings | The dataset with settings to populate |
Events
SettingsChanged
Triggered whenever changes are made to plugin settings
Declaration
public static event EventHandler SettingsChanged
Event Type
Type | Description |
---|---|
System. |
Remarks
The source of the event is the PlugInDescriptor for which the changes apply, check for example ((PlugInDescriptor)source).AssemblyName to see if this event applies to your logic if needed.