Skip to content

Immutable config

Piotr Szkudlarski edited this page Dec 15, 2018 · 4 revisions

Library needs to match constructor parameter with property / field and it does it as described in rule 2. below. See given example constructor parameter (testConfigurations) matches with no case sensitive comparison with property name (TestConfigurations).

Rules:

  1. library gets first constructor decorated by IniConstructor attribute
  2. library first tries to match constructor parameters with properties / fields by name with case sensitive comparison. If nothing is found library tries to compare with StringComparison.InvariantCultureIgnoreCase.
  3. if file does not contain value for property / field or if rule 2. does not find match library uses default value of property / field type.
public class ImmutableListOfComplexDataConfiguration
{
    public IEnumerable<ImmutableConfiguration> TestConfigurations { get;}

    [IniConstructor]
    public ImmutableListOfComplexDataConfiguration(IEnumerable<ImmutableConfiguration> testConfigurations)
    {
        TestConfigurations = testConfigurations;
    }
}
Clone this wiki locally