ConfigUtil 1.0.1
See the version list below for details.
dotnet add package ConfigUtil --version 1.0.1
NuGet\Install-Package ConfigUtil -Version 1.0.1
<PackageReference Include="ConfigUtil" Version="1.0.1" />
paket add ConfigUtil --version 1.0.1
#r "nuget: ConfigUtil, 1.0.1"
// Install ConfigUtil as a Cake Addin #addin nuget:?package=ConfigUtil&version=1.0.1 // Install ConfigUtil as a Cake Tool #tool nuget:?package=ConfigUtil&version=1.0.1
Small utility for loading/saving properties of .Net classes as string values into app.config file or other sources(Json/XML,...)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
All you should do is to decorate you properties with ConfigProp attribute, you can specify default value and custom title for properties too, then you should call this.LoadConfiguration() method in class constructor any method.
public class ImageSlider
{
[ConfigProp]
public string OverlayText { get; set; }
[ConfigProp(true)]//default value is true (in case of absence of this property value in app config true will be assigned)
public bool ShowOverlayText { get; set; }
[ConfigProp(5)]
public int ImageCount { get; set; }
[ConfigProp("Red")]
public Color BgColor { get; set; }
[ConfigProp("10,10,10,10,10")]
public List<int> ImagesDelay { get; set; }
[ConfigProp]
public DateTime CreateDate { get; set; }
[ConfigProp(Name = "Delay")]//Delay is the key to load value from app.config
public TimeSpan TransitionDelay { get; set; }
public ImageSlider(){
this.LoadConfiguration();//loads the configuration from app.config file (appSettings section)
}
public void SaveConfig(){
this.LoadConfiguration();//Writes properties values to the app.config file (appSettings section)
}
public void SaveDefaultConfig(){
this.SaveDefaultConfiguration();//Writes properties default values to the app.config file (appSettings section)
}
}
You can use other sources instead of app.config too (https://github.com/bashiransary/ConfigUtil/wiki/Config-Sources)
ConfigUtil supports most of common data types (https://github.com/bashiransary/ConfigUtil/wiki/Supported-Datatypes)