Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this require a concrete class or can we set and get values directly? #30

Open
Shadowblitz16 opened this issue Nov 17, 2021 · 1 comment

Comments

@Shadowblitz16
Copy link

Shadowblitz16 commented Nov 17, 2021

I just looked at toml and I like the syntax mush more then json.
However I am looking for something like this in a toml library...

var tomlFile = new TomlFile(filepath);
tomlFile.Set<T>(T value); //create if doesn't exist and sets it
T value = tomlFile.Get<T>(); //gets the value or default.
tomlFile.Save(); //optional filepath

Is this supported if not how hard would it be to do?

Edit: btw the name and avatar of this library made me laugh.

@dezhidki
Copy link
Owner

Hi!

Sorry for not answering earlier. Tommy's API followed that of SimpleJSON and was made for quick and low-level access to a TOML document. I, therefore, tried to be careful with terminology and called Tommy a TOML reader and writer instead of "deserialiser and serialiser".

If you need higher-level access, you can write extensions on top of Tommy that implement it. There are already some basic implementations, for example.

  • instance-id/Tommy.Serializer implements a full serialiser. Although the project isn't seemingly maintained actively, upgrading it to Tommy 3.0.0 should be possible.
  • Tommy.Extensions.Configuration NuGet package implements Microsoft.Extensions.Configuration-compliant TOML loading. With it, you can use the standard Options API that you may be familiar with from ASP.NET Core

There are also other TOML implementations for C# that take a more high-level approach. I am aware of [SamboyCoding/Tomlet(https://github.com/SamboyCoding/Tomlet), which has a full-blown (de)serialiser as part of the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants