[This is preliminary documentation and is subject to change.]
Namespace: ContentStudio.EventActions.SynchronousEventHandlers
Assembly: SyncEvtHand (in SyncEvtHand.dll) Version: 1.0.0.0 (1.0.0.0)
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: ConfigurationThe Configuration object that represents the custom configuration file.
Exception | Condition |
---|---|
ArgumentNullException | |
FileNotFoundException | |
ConfigurationErrorsException | |
InvalidOperationException | No configuration returned |
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.
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;