ConnectorLib .NET 24.2

# Read Configuration Parameters

All of the fetch action methods you can override in `ConnectorBase` are passed a `task` object with a `TaskConfig` property of type `ITaskConfig`. You can use this property to read configuration settings from the task's configuration.

NOTE: The task configuration returned by the methods of the `TaskConfig` property can be different to what is specified in the configuration file. This is because the settings in the configuration file can be overridden by settings passed to ACI actions.

The following lines demonstrate how to read string, integer and Boolean values:

           string param = task.TaskConfig.Read("Param", "DefaultValue");
           int numeric = task.TaskConfig.Read("Numeric", 6);
           bool boolean = task.TaskConfig.Read("Boolean", true);

Each of the methods called above takes the name of the parameter to read and the default value to return if the parameter is not specified. Values for these parameters might be specified in a configuration file like this:

           Param=MyValue
           Numeric=4
           Boolean=False

ConnectorLib .NET also provides methods for reading parameters that are required. When a required parameter is not set, the `ReadRequired` method throws a `BadConfigurationException` with a descriptive message.

           string required = task.TaskConfig.ReadRequired("Required");

You can read encrypted values (such as passwords that were encrypted with autpassword.exe) using the `ReadPassword` and `ReadRequiredPassword` methods:

           string password = task.TaskConfig.ReadRequiredPassword("Password");

## Use Enumerations

If you have an enumeration defined, for example:

           enum Shape { Square, Circle, Triangle };

...you can read the value of a parameter and automatically convert it to a value in the enumeration. To do this, use the `ReadEnum` method:

           Shape shape = task.TaskConfig.ReadEnum("Shape", Shape.Circle);

The `Shape` parameter might be specified in the configuration file like this:

           Shape=Triangle

The values set in the configuration file and read by `ReadEnum` are not case-sensitive.

The `ReadEnum` method throws a `BadConfigurationException` if the `Shape` parameter is not set to the name of one of the members of the enumeration.

## Read Proxy Settings

The `WebProxyReader` in the `Autonomy.Connector.Utilities` namespace allows you to read web proxy settings from a configuration parameter. The following example reads proxy settings from the `ProxySettings` parameter:

           IWebProxy proxy = WebProxyReader.Read(
            	task.TaskConfig, "ProxySettings");

This parameter might be specified in the configuration file like this:

           ProxySettings=http://proxyserver:8080/

To use system settings, a user can set the parameter to `auto`. If the parameter is not set, no proxy is used.

Copyright 2024 Open Text
Version 24.2 | Last updated March 2024

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: IDOL ConnectorLib .NET 24.2

Topic Title: Read Configuration Parameters