-
Notifications
You must be signed in to change notification settings - Fork 0
Attributes
Piotr Szkudlarski edited this page Dec 11, 2018
·
9 revisions
If you want to override default evaluation of Section or Key values you can use IniOptions attribute and pass Section and Key.
public class AttributeTestConfiguration
{
[IniOptions(Key = "OverrideDefaultKeyEvaluation", Section = "OverrideDefaultSectionEvaluation"]
public string TestString { get; set; }
}You can also specify only one value either Key or Section.
public class AttributeTestConfiguration
{
[IniOptions(Section = "OverrideDefaultSectionEvaluation"]
public string TestString { get; set; }
}public class AttributeTestConfiguration
{
[IniOptions(Key = "OverrideDefaultKeyEvaluation"]
public string TestString { get; set; }
}If you don't want to save / load property from ini file you can use IniIgnore attribute as shown below.
public class IgnoreAttributeTestConfiguration
{
[IniIgnore]
public string TestString { get; set; }
}If you want to specify custom behaviour you can use IniConverter attribute and implement your own converter. For more information please go to Custom Converter
public class BoolBinaryConverterConfiguration
{
[IniConverter(typeof(BoolBinaryConverter))]
public bool TestBool { get; set; }
}If you have:
- immutable configuration class or
- class without default parameterless constructor or
- want to use specific constructor
you can use IniConstructorAttribute to tell framework which constructor to use when creating instance of this class. You can find more information in Immutable config section.
public class ImmutableListOfComplexDataConfiguration
{
public IEnumerable<ImmutableConfiguration> TestConfigurations { get;}
[IniConstructor]
public ImmutableListOfComplexDataConfiguration(IEnumerable<ImmutableConfiguration> testConfigurations)
{
TestConfigurations = testConfigurations;
}
}