DsSimpleSettings 2.2.5
See the version list below for details.
dotnet add package DsSimpleSettings --version 2.2.5
NuGet\Install-Package DsSimpleSettings -Version 2.2.5
<PackageReference Include="DsSimpleSettings" Version="2.2.5" />
paket add DsSimpleSettings --version 2.2.5
#r "nuget: DsSimpleSettings, 2.2.5"
// Install DsSimpleSettings as a Cake Addin #addin nuget:?package=DsSimpleSettings&version=2.2.5 // Install DsSimpleSettings as a Cake Tool #tool nuget:?package=DsSimpleSettings&version=2.2.5
SimpleSettings
SimpleSettings is a small library that allows easy access to settings reading and writing, with user-defined class blueprints.
In this version
This version brings a few minor changes:
- It was not intended that static properties were read or written from/to files. This has been fixed.
- The library now has its own base exception class from which all custom exceptions will inherit.
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 create a template settings file from this class, call Settings.WriteTemplate<MySettings>()
.
To save the settings to a file, call Settings.ToFile(mySettingsInstance, "path/to/file.txt")
.
The WriteTemplate method uses the default value and the description. 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 and WriteTemplate methods from instances.
A class must have a parameterless constructor, otherwise the settings loader cannot create a new instance of the class.
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.