ktsu.AppDataStorage 1.1.27

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package ktsu.AppDataStorage --version 1.1.27                
NuGet\Install-Package ktsu.AppDataStorage -Version 1.1.27                
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="ktsu.AppDataStorage" Version="1.1.27" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ktsu.AppDataStorage --version 1.1.27                
#r "nuget: ktsu.AppDataStorage, 1.1.27"                
#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 ktsu.AppDataStorage as a Cake Addin
#addin nuget:?package=ktsu.AppDataStorage&version=1.1.27

// Install ktsu.AppDataStorage as a Cake Tool
#tool nuget:?package=ktsu.AppDataStorage&version=1.1.27                

ktsu.AppDataStorage

ktsu.AppDataStorage is a .NET library designed to simplify the process of storing application data. This library enables you to save and load configuration or state data in the application data folder of the current user, using JSON serialization.

Features

  • Easy-to-use: Simple interface for saving and loading application data.
  • Automatic Backup: Ensures that the original data is backed up before saving.
  • Customizable Serialization: Uses System.Text.Json with support for custom converters.
  • File System Abstraction: Uses System.IO.Abstractions for easy testing.

Installation

Install the package via NuGet:

dotnet add package ktsu.AppDataStorage

Usage

Define Your App Data Class

Create a class that inherits from AppData<T> where T is your class type.

public class MyAppData : AppData<MyAppData>
{
    public string Setting1 { get; set; } = "hello";
    public int Setting2 { get; set; } = 12;
}

Load Data

To load data, call the LoadOrCreate method. If the data file doesn't exist or is invalid, a new instance will be created and saved.

var data = MyAppData.LoadOrCreate();
Console.WriteLine(data.Setting1);
Console.WriteLine(data.Setting2);

// Output:
// hello
// 12

Save Data

To save data, call Save on the instance of your app data class, after modifying its properties.

var data = MyAppData.LoadOrCreate();
data.Setting1 = "goodbye";
data.Setting2 = 42;
data.Save();

var data2 = MyAppData.LoadOrCreate();
Console.WriteLine(data2.Setting1);
Console.WriteLine(data2.Setting2);

// Output:
// goodbye
// 42

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on ktsu.AppDataStorage:

Package Downloads
ktsu.CredentialCache

CredentialCache

ktsu.SingleAppInstance

A library to ensure that only one instance of an application is running at a time.

ktsu.GitIntegration

Git Integration

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.7 566 1/3/2025
1.4.7-pre.23 0 1/31/2025
1.4.7-pre.22 28 1/30/2025
1.4.7-pre.21 5 1/29/2025
1.4.7-pre.20 28 1/28/2025
1.4.7-pre.19 24 1/27/2025
1.4.7-pre.18 28 1/26/2025
1.4.7-pre.17 11 1/24/2025
1.4.7-pre.16 28 1/22/2025
1.4.7-pre.15 26 1/20/2025
1.4.7-pre.14 35 1/18/2025
1.4.7-pre.13 38 1/16/2025
1.4.7-pre.12 9 1/14/2025
1.4.7-pre.11 27 1/13/2025
1.4.7-pre.10 35 1/11/2025
1.4.7-pre.9 28 1/10/2025
1.4.7-pre.8 31 1/10/2025
1.4.7-pre.7 11 1/8/2025
1.4.7-pre.6 43 1/7/2025
1.4.7-pre.5 49 1/5/2025
1.4.7-pre.4 65 1/3/2025
1.4.7-pre.3 46 1/3/2025
1.4.7-pre.2 50 1/3/2025
1.4.7-pre.1 52 1/3/2025
1.4.6 103 1/2/2025
1.4.5 96 1/2/2025
1.4.4 85 1/2/2025
1.4.3 83 1/2/2025
1.4.2 88 1/2/2025
1.4.1 84 1/2/2025
1.4.0 84 1/2/2025
1.3.16 298 1/2/2025
1.3.16-pre.6 54 1/2/2025
1.3.16-pre.5 72 12/31/2024
1.3.16-pre.4 47 12/30/2024
1.3.16-pre.3 49 12/29/2024
1.3.16-pre.2 45 12/28/2024
1.3.16-pre.1 45 12/27/2024
1.3.15 194 12/27/2024
1.3.14 81 12/27/2024
1.3.13-pre.1 47 12/27/2024
1.3.12-pre.1 45 12/27/2024
1.3.11-pre.1 48 12/27/2024
1.3.10 122 12/26/2024
1.3.10-pre.1 45 12/27/2024
1.3.9 123 12/26/2024
1.3.8 81 12/26/2024
1.3.7 77 12/26/2024
1.3.6 76 12/26/2024
1.3.5 88 12/26/2024
1.3.4 90 12/26/2024
1.3.3 129 12/25/2024
1.3.2 242 12/23/2024
1.3.1 105 12/23/2024
1.3.0 80 12/23/2024
1.2.4 77 12/23/2024
1.2.3 129 12/22/2024
1.2.2 83 12/22/2024
1.2.1 101 12/22/2024
1.2.0 85 12/22/2024
1.1.57 142 12/19/2024
1.1.56 132 12/19/2024
1.1.55 163 12/17/2024
1.1.54 137 12/16/2024
1.1.53 265 12/9/2024
1.1.52 167 12/6/2024
1.1.51 181 12/5/2024
1.1.50 116 12/5/2024
1.1.49 129 12/4/2024
1.1.48 169 12/2/2024
1.1.47 87 12/2/2024
1.1.46 107 12/2/2024
1.1.45 99 12/2/2024
1.1.44 99 12/2/2024
1.1.43 112 12/1/2024
1.1.42 96 12/1/2024
1.1.41 167 12/1/2024
1.1.40 103 12/1/2024
1.1.39 133 11/30/2024
1.1.38 97 11/30/2024
1.1.37 111 11/29/2024
1.1.36 136 11/28/2024
1.1.35 140 11/27/2024
1.1.34 135 11/26/2024
1.1.33 235 11/20/2024
1.1.32 132 11/19/2024
1.1.31 156 11/15/2024
1.1.30 120 11/14/2024
1.1.29 139 11/13/2024
1.1.28 131 11/12/2024
1.1.27 140 11/11/2024
1.1.26 130 11/8/2024
1.1.25 136 11/6/2024
1.1.24 132 11/5/2024
1.1.23 139 11/4/2024
1.1.22 241 11/2/2024
1.1.21 103 11/1/2024
1.1.20 380 10/18/2024
1.1.19 324 10/9/2024
1.1.18 114 10/8/2024
1.1.17 98 10/7/2024
1.1.16 115 10/4/2024
1.1.15 200 9/25/2024
1.1.14 121 9/24/2024
1.1.13 112 9/23/2024
1.1.12 121 9/20/2024
1.1.11 123 9/19/2024
1.1.10 115 9/19/2024
1.1.9 85 9/19/2024
1.1.8 121 9/19/2024
1.1.7 160 9/18/2024
1.1.6 110 9/18/2024
1.1.5 101 9/18/2024
1.1.4 112 9/18/2024
1.1.3 153 9/14/2024
1.1.2 124 9/14/2024