Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jzo001/forge.wasm.browserstorages.newtonsoft.json
Newtonsoft.Json serialization for BrowserStorages
https://github.com/jzo001/forge.wasm.browserstorages.newtonsoft.json
blazor localstorage localstorage-api provider serialization sessionstorage sessionstorage-api wasm webassembly
Last synced: 1 day ago
JSON representation
Newtonsoft.Json serialization for BrowserStorages
- Host: GitHub
- URL: https://github.com/jzo001/forge.wasm.browserstorages.newtonsoft.json
- Owner: JZO001
- License: mit
- Created: 2022-10-16T20:18:43.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-25T14:23:26.000Z (over 1 year ago)
- Last Synced: 2024-12-15T23:37:58.226Z (20 days ago)
- Topics: blazor, localstorage, localstorage-api, provider, serialization, sessionstorage, sessionstorage-api, wasm, webassembly
- Language: C#
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Forge.Wasm.BrowserStorages.NewtonSoft.Json
Forge.Wasm.BrowserStorages.NewtonSoft.Json is a library extension that provides Nettonsoft.Json serialization provider Forge.Wasm.BrowserStorages library.## Installing
To install the package add the following line to you csproj file replacing x.x.x with the latest version number:
```
```
You can also install via the .NET CLI with the following command:
```
dotnet add package Forge.Wasm.BrowserStorages.NewtonSoft.Json
```If you're using Visual Studio you can also install via the built in NuGet package manager.
## Setup
You will need to register the local storage services with the service collection in your _Startup.cs_ file in Blazor Server.
```c#
public void ConfigureServices(IServiceCollection services)
{
// ... preinitialization steps// always add this code after the "Forge.Wasm.BrowserStorages" library initialization
services.AddForgeLocalStorageWithNewtonsoftSerializer();
services.AddForgeSessionStorageWithNewtonsoftSerializer();
}
```Or in your _Program.cs_ file in Blazor WebAssembly.
```c#
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add("app");// ... preinitialization steps
// always add this code after the "Forge.Wasm.BrowserStorages" library initialization
builder.Services.AddForgeLocalStorageWithNewtonsoftSerializer();
builder.Services.AddForgeSessionStorageWithNewtonsoftSerializer();await builder.Build().RunAsync();
}
```### Registering services as Singleton
If you would like to register the serialization provider as singletons, it is possible by using the following method:```csharp
builder.Services.AddForgeLocalStorageAsSingletonWithNewtonsoftSerializer();
builder.Services.AddForgeSessionStorageAsSingletonWithNewtonsoftSerializer();
```This method is not recommended in the most cases, try to avoid using it.
Please also check the following projects in my repositories:
- Forge.Yoda
- Forge.Security.Jwt.Service
- Forge.Security.Jwt.Service.Storage.SqlServer
- Forge.Security.Jwt.Client
- Forge.Security.Jwt.Client.Storage.Browser
- Forge.Wasm.BrowserStorages
- Forge.Wasm.BrowserStorages.NewtonSoft.Json