DsSimpleSettings 3.0.1
See the version list below for details.
dotnet add package DsSimpleSettings --version 3.0.1
NuGet\Install-Package DsSimpleSettings -Version 3.0.1
<PackageReference Include="DsSimpleSettings" Version="3.0.1" />
paket add DsSimpleSettings --version 3.0.1
#r "nuget: DsSimpleSettings, 3.0.1"
// Install DsSimpleSettings as a Cake Addin #addin nuget:?package=DsSimpleSettings&version=3.0.1 // Install DsSimpleSettings as a Cake Tool #tool nuget:?package=DsSimpleSettings&version=3.0.1
SimpleSettings
SimpleSettings is a small library that allows easy access to settings reading and writing, with user-defined class blueprints.
In this version
This is marked as a major update, which means that stuff breaks when you update.
- WriteTemplate is removed in favour of ToFile.
- Write templates by calling ToFile with null as instance.
- Methods that use IO are more generalised so you can insert your own TextReaders/Writers.
- You can now pass instances of a class to the library to overwrite the settings in given instance.
- This library is now unit tested!
Usage
Using this library is very straightforward. One simply needs to create a class with publicly exposed properties and call the library function to load settings into it.
MySettings.cs
using SimpleSettings;
namespace MyProject
{
class MySettings
{
public string MyFirstSetting { get; set; }
[Description("This is a very important integer value")]
[Default(2)]
public int MySecondSetting { get; set; }
[Description("This class has a public method called 'Parse'")]
public SomeClass MyThirdSetting { get; set; }
[Ignore]
public float MyIgnoredSetting { get; set; } // this setting gets ignored by the settings reader
[Group("My group!")]
public float MyFirstGroupSetting { get; set; }
[Group("My group!")]
public System.Version MySecondGroupSetting { get; set; }
}
}
To read settings from a file into an instance of this class, one simply has to call Settings.FromFile<MySettings>("path/to/file.txt")
.
To save the settings to a file, call Settings.ToFile(mySettingsInstance, "path/to/file.txt")
.
To create a template settings file from this class, call Settings.ToFile<MySettings>(null, "path/to/file.txt")
.
The output would look like this:
MySettings_template.txt
;===(My group!)===
MyFirstGroupSetting:0
MySecondGroupSetting:
;=================
MyFirstSetting:
; This is a very important integer value
MySecondSetting:2
; This class has a public method called 'Parse'
MyThirdSetting:
Alternatively, the class can inherit the Settings
class and can then call the ToFile methods from instances.
The library can only create instances of classes that have a parameterless constructor. If your class doesn't have a parameterless constructor, you will have to create an instance yourself and pass that instance to the library instead.
If you have found a bug, something doesn't work as you would expect or you think this package could be improved in any way, please submit a feature request or bug report on the GitHub page of this project: https://github.com/D-Inventor/SimpleSettings
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- 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.
- WriteTemplate is removed in favour of ToFile.
- Create templates by calling ToFile with null as instance argument.
- Now completely unit tested.
- All methods that perform IO are more generalised, so you can insert your own TextReaders/Writers.
- You can now give the FromFile method an instance of a class to overwrite the values in that class with the desired settings. This is useful for example when your class does not have a parameterless constructor.