IConfigurable

Description

interface Tinman.Core.Config.Binding.IConfigurable

Base interface for classes that can express their structure as a config value.

Public / Methods

To​Config


public method ToConfig → ()

returns → ConfigValue

The configuration value or ConfigValue.Invalid (see remarks).

Returns the configuration value that describes this object.

Each class that implements this interface is associated with a IConfigurator object, which performs the actual conversion to and from ConfigValue. By convention, the type should declare a public and static read-only property named Config, to make the association explicit:

public static IConfigurator<MyClass> Config
{
  get { return ...; }
}

Calling ToConfig is equivalent to calling IConfigurator.ToValue on the associated configurator. However, passing null to the configurator does not necessarily return ConfigValue.Null. Use the IConfigurableNull base interface to communicate that an implementation always maps null to ConfigValue.Null.

The returned value may be of type ConfigType.Invalid, which means that this object in its current state cannot be described with the configuration API.

Before returning the resulting configuration value, ConfigValue.Cache must be called on it iff it is mutable (see ConfigValue.IsImmutable), passing this IConfigurable object as parameter.

ConfigException

If an unexpected error has occurred while building the config value.