ktsu.AppDataStorage
1.1.20
Prefix Reserved
See the version list below for details.
dotnet add package ktsu.AppDataStorage --version 1.1.20
NuGet\Install-Package ktsu.AppDataStorage -Version 1.1.20
<PackageReference Include="ktsu.AppDataStorage" Version="1.1.20" />
paket add ktsu.AppDataStorage --version 1.1.20
#r "nuget: ktsu.AppDataStorage, 1.1.20"
// Install ktsu.AppDataStorage as a Cake Addin #addin nuget:?package=ktsu.AppDataStorage&version=1.1.20 // Install ktsu.AppDataStorage as a Cake Tool #tool nuget:?package=ktsu.AppDataStorage&version=1.1.20
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 | Versions 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. |
-
net7.0
- ktsu.CaseConverter (>= 1.0.12)
- ktsu.StrongPaths (>= 1.1.17)
- ktsu.StrongStrings (>= 1.2.8)
- ktsu.ToStringJsonConverter (>= 1.0.14)
- TestableIO.System.IO.Abstractions (>= 21.0.29)
- TestableIO.System.IO.Abstractions.Wrappers (>= 21.0.29)
-
net8.0
- ktsu.CaseConverter (>= 1.0.12)
- ktsu.StrongPaths (>= 1.1.17)
- ktsu.StrongStrings (>= 1.2.8)
- ktsu.ToStringJsonConverter (>= 1.0.14)
- TestableIO.System.IO.Abstractions (>= 21.0.29)
- TestableIO.System.IO.Abstractions.Wrappers (>= 21.0.29)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ktsu.AppDataStorage:
Package | Downloads |
---|---|
ktsu.CredentialCache
CredentialCache |
|
ktsu.GitIntegration
Git Integration |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.30 | 0 | 11/14/2024 |
1.1.29 | 50 | 11/13/2024 |
1.1.28 | 58 | 11/12/2024 |
1.1.27 | 96 | 11/11/2024 |
1.1.26 | 103 | 11/8/2024 |
1.1.25 | 110 | 11/6/2024 |
1.1.24 | 104 | 11/5/2024 |
1.1.23 | 112 | 11/4/2024 |
1.1.22 | 172 | 11/2/2024 |
1.1.21 | 76 | 11/1/2024 |
1.1.20 | 361 | 10/18/2024 |
1.1.19 | 301 | 10/9/2024 |
1.1.18 | 91 | 10/8/2024 |
1.1.17 | 77 | 10/7/2024 |
1.1.16 | 98 | 10/4/2024 |
1.1.15 | 177 | 9/25/2024 |
1.1.14 | 103 | 9/24/2024 |
1.1.13 | 93 | 9/23/2024 |
1.1.12 | 102 | 9/20/2024 |
1.1.11 | 104 | 9/19/2024 |
1.1.10 | 99 | 9/19/2024 |
1.1.9 | 68 | 9/19/2024 |
1.1.8 | 104 | 9/19/2024 |
1.1.7 | 143 | 9/18/2024 |
1.1.6 | 94 | 9/18/2024 |
1.1.5 | 86 | 9/18/2024 |
1.1.4 | 97 | 9/18/2024 |
1.1.3 | 140 | 9/14/2024 |
1.1.2 | 111 | 9/14/2024 |