Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shadowsocks-net/openonlineconfig.net
.NET class library for Open Online Config (OOC) support.
https://github.com/shadowsocks-net/openonlineconfig.net
Last synced: 22 days ago
JSON representation
.NET class library for Open Online Config (OOC) support.
- Host: GitHub
- URL: https://github.com/shadowsocks-net/openonlineconfig.net
- Owner: Shadowsocks-NET
- License: mit
- Created: 2021-07-05T13:35:07.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-21T11:58:27.000Z (almost 2 years ago)
- Last Synced: 2024-12-12T07:34:23.029Z (25 days ago)
- Language: C#
- Size: 28.3 KB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `OpenOnlineConfig.NET`
[![Nuget](https://img.shields.io/nuget/v/OpenOnlineConfig)](https://www.nuget.org/packages/OpenOnlineConfig/)
[![Build & Test](https://github.com/Shadowsocks-NET/OpenOnlineConfig.NET/actions/workflows/build.yml/badge.svg)](https://github.com/Shadowsocks-NET/OpenOnlineConfig.NET/actions/workflows/build.yml)
[![Publish NuGet Package](https://github.com/Shadowsocks-NET/OpenOnlineConfig.NET/actions/workflows/publish.yml/badge.svg)](https://github.com/Shadowsocks-NET/OpenOnlineConfig.NET/actions/workflows/publish.yml)`OpenOnlineConfig.NET` is a .NET class library for Open Online Config (OOC) support.
## Supported Open Online Config Versions
- [OOCv1](https://github.com/Shadowsocks-NET/OpenOnlineConfig/blob/master/docs/0001-open-online-config-v1.md)
## Usage
### 1. API Token
`OOCv1ApiToken` is an immutable record type. It can be used to serialize and deserialize API tokens.
``` cs
// Serialize an API token.
var token = new OOCv1ApiToken(1, "https://example.com", "8c1da4d8-8684-4a2c-9abb-57b9d5fa7e52", "a117460e-41df-4dbd-b2df-4bd0c16efd2f", null);
var json = JsonSerializer.Serialize(token, JsonHelper.camelCaseMinifiedJsonSerializerOptions);
`````` cs
// Deserialize an API token.
var json = "{\"version\":1,\"baseUrl\":\"https://example.com\",\"secret\":\"8c1da4d8-8684-4a2c-9abb-57b9d5fa7e52\",\"userId\":\"a117460e-41df-4dbd-b2df-4bd0c16efd2f\"}";
var token = JsonSerializer.Deserialize(json, JsonHelper.camelCaseJsonDeserializerOptions);
```### 2. Config Base
`OOCv1ConfigBase` is the minimal OOCv1 config type. To use this type, inherit from it and add protocol-specific properties.
### 3. API Client
`OOCv1ApiClient` is the general-purpose OOCv1 API client. Use this if you want to handle the response JSON yourself.
`OOCv1ApiClient` is the generic OOCv1 API client. Use this if you have specific protocols in mind. `T` must be a subclass of `OOCv1ConfigBase`.
## License
The project is licensed under the [MIT license](LICENSE).