DsSimpleSettings 2.3.0
See the version list below for details.
dotnet add package DsSimpleSettings --version 2.3.0
NuGet\Install-Package DsSimpleSettings -Version 2.3.0
<PackageReference Include="DsSimpleSettings" Version="2.3.0" />
paket add DsSimpleSettings --version 2.3.0
#r "nuget: DsSimpleSettings, 2.3.0"
// Install DsSimpleSettings as a Cake Addin #addin nuget:?package=DsSimpleSettings&version=2.3.0 // Install DsSimpleSettings as a Cake Tool #tool nuget:?package=DsSimpleSettings&version=2.3.0
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 back what was removed as a bug:
- You can now target static properties as settings, using the
StaticSetting
attribute. - Everything in this package now comes with documentation!
- This package was supposed to have a standard MIT license, but I am currently unable to actually put it on the package.
- In the near future, I might be reworking the attributes a bit, because currently it's becoming really cluttered. Beware for a 3.0.0 release somewhere soon!
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.
With this release, an old feature returns. Static settings can now be read and written by explicitly adding the 'StaticSettings' attribute to any static property.