Clone wiki

configreader / CustomConversions

Configuring custom conversions for types

The config reader tries to convert types from their string representation by using an associated TypeConverter.

For types that do not have a TypeConverter specified, a custom converter should be setup.

For example, the code:

    var configReader = new ConfigurationReader();

        SetupCustomConverter(source => source.Split(';')).
        SetupCustomConverter(source => IPAddress.Parse(source)).

which sets up custom converter for the types IPAddress and string Array, enables reading the configuration for the interface:

    public interface ICustomConversion
        IPAddress Address { get; }
        string[] StringArray { get; }

The custom converters take precedence over the TypeConverter in one is defined.