SynchronousEventHandlerBaseGetCustomConfiguration Method Content Studio 5.7 SDK
Content Studio Web Content Management System

[This is preliminary documentation and is subject to change.]

Gets a configuration file with a specific name. This file is located in the same directory as the Content Studio runtime.

Namespace: ContentStudio.EventActions.SynchronousEventHandlers
Assembly: SyncEvtHand (in SyncEvtHand.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax

public Configuration GetCustomConfiguration(
	string fileName
)

Parameters

fileName
Type: SystemString
Name of the configuration file. This file must be placed in the same directory as the Content Studio runtime service.

Return Value

Type: Configuration
The Configuration object that represents the custom configuration file.
Exceptions

Remarks

Note Note
This method was added in Content Studio 5.3

Sometimes an event handler needs its own configuration data and it is tempting to place this configuration data in the CSServiceHost.exe.config file used by the hosting service. However, this is a bad idea since this file is maintained by the Content Studio installation program an is overwritten each time Content Studio is upgraded. Instead you should create a configuration file private to your event actions event handler. You can name it according to the assembly of your handler ex. Myhandler.dll.config and read it using this method.

As an alternative you can pass arbitrary string data in the customData parameter. You then override the ParseCustomData(String) metod to extract that data. The advantage with this method is that you can let a Content Studio administrator change configuration data directly from the event actions dialog. However if the event handler serves many categories the configuration file migth be more convenient.

Examples

The following example shows how to read a connection string value named MyDatabase from a private configuration file named MyHandler.dll.config. You will need a reference to the System.Configuration assembly in order to compile the example.

System.Configuration.Configuration config = GetCustomConfiguration("MyHandler.dll.config");
string connectionString = config.ConnectionStrings.ConnectionStrings["MyDatabase"].ConnectionString;
See Also

Reference