TheVeryStarlk / Natron

An extermely simple to use data persistance library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quick Start

Natron does not have a NuGet package *yet*
Clone and reference the class library project ("Natron.Library").

Usage Example

Natron provides simple and straight-forward usage API. More advanced features are coming soon.

using Natron.Library.Builder;
using Natron.Library.Containers;
using Natron.Library.Serializers;

var account = new Account("Starlk");

var path = Path.Combine(Directory.GetCurrentDirectory(), "account");

var configuration = Natron<Account>.Configure(account)
    .UseContainers(() => new ContainerBase[]
    {
        new FileContainer(path)
    })
    .UseSerializers(() => new SerializerBase[]
    {
        new JsonSerializer()
    })
    .Build();

account.Name = "John";

await configuration.PersistAsync();

internal sealed class Account
{
    public string Name { get; set; }

    public Account(string name)
    {
        Name = name;
    }
}

This sample serializes and saves the account class instance into a JSON file ("account.json").

{"Name":"John"}

Extensibility

Natron allows for custom implementations for containers and serializers. To create your own container/serializer inherit from their base class.
See the FileContainer or the JsonSerializer for examples.

About

An extermely simple to use data persistance library.

License:GNU Lesser General Public License v3.0


Languages

Language:C# 100.0%