SimpleSamSettings.Framework 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SimpleSamSettings.Framework --version 1.0.0                
NuGet\Install-Package SimpleSamSettings.Framework -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleSamSettings.Framework" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleSamSettings.Framework --version 1.0.0                
#r "nuget: SimpleSamSettings.Framework, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SimpleSamSettings.Framework as a Cake Addin
#addin nuget:?package=SimpleSamSettings.Framework&version=1.0.0

// Install SimpleSamSettings.Framework as a Cake Tool
#tool nuget:?package=SimpleSamSettings.Framework&version=1.0.0                

SimpleSamSettings

Simple, cross-platform settings framework based on the idea of many distinct settings classes are better than one huge one. Persistence is configurable, as is the location.

Every application requires user-, application-, and other defined settings. The maintenance of these settings can be horrendous over time if not property architectured and maintained.

SimpleSameSettings aims to ease the burden of creating, managing, saving, and restoring settings for any application in .NET Standard.

Demo app

  • See the SimpleSamSettings.Demo WPF application

Quick Start Example

public class MySettings : OverwriteSettingsProfile<MySettings> 
{
   public string SomeProp
   {
      get => Get<string>();
      set => Set(value);
   }
}

Globals.SettingsFileBasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MyAppName");

That's it! Your settings will be persisted to %appdata%/MyAppName/MySettings.settings in JSON format. Prefer binary? No problem! Put the [Serializable] tag on it and it will auto-serialize as binary.

By default, each change updates the file on disk. To turn off this behavior, simply set AutoSave to false, like this:

var settings = new MySettings() { AutoSave = false };

...then at any time, you can save it (say, on application exit):

settings.SaveInstance() OR MySettings.Save(); // OverwriteSettingsProfile<> ensures a singleton instance, so it is a static helper method

Undoing settings changes - the easy way!

Say you have a dialog open for the user to change settings. The settings changes are live, ideally, but if the user clicks 'Cancel' everything they've done during the lifetime of that dialog should be undoe. Easy peasy!

Simply set the 'MakeUndoable' flag in the base to true.

settings.MakeUndoable = true;

... do your stuff in the dialog ...

To cancel or undo everything:

settings.RevertChanges();

Then set MakeUndoable back to false so it doesn't save off changes:

settings.MakeUndoable = false;

Usage Advice

Encapsulate your settings into small classes - many, properly encapsulated classes is preferred over one or a few very large ones! This makes it easier to maintain, easier to use and reuse, and speeds up disk i/o.

NOTE:

If a collection or object inside the settings class changes, the file will not be autosaved. It is recommended that the settings class listen for changes on those objects and auto-saves them, as appropriate, but this is in no way enforced and left entirely up to the consumer (you). Happy settings coding!

Created & Maintained By

Brent Bulla (@outbred)

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 651 5/14/2019
1.0.1 743 10/14/2018
1.0.0 764 10/14/2018

Intial version with demo