SimpleConfigs 1.2.1

dotnet add package SimpleConfigs --version 1.2.1
                    
NuGet\Install-Package SimpleConfigs -Version 1.2.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleConfigs" Version="1.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleConfigs" Version="1.2.1" />
                    
Directory.Packages.props
<PackageReference Include="SimpleConfigs" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SimpleConfigs --version 1.2.1
                    
#r "nuget: SimpleConfigs, 1.2.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SimpleConfigs@1.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SimpleConfigs&version=1.2.1
                    
Install as a Cake Addin
#tool nuget:?package=SimpleConfigs&version=1.2.1
                    
Install as a Cake Tool

🚀 About Me

Hello, my - linkedin

Documentation

Target framework

Releases only on: .Net8

Assemblies

<div id="SimpleConfigs"></div>

SimpleConfigs - The core library provides all necessary functional for configs creating, saving, loading etc. Don't have any external dependencies. But it not contains implementation for ISerializationManager interface.

<div id="SimpleConfigs.JSON"></div>

SimpleConfigs.JSON - Contain implementation for ISerializationManager interface, which give ability to serialize config in JSON format. Depends on: SimpleConfigs, Newtonsoft.JSON.

<div id="SimpleConfigs.Examples"></div>

SimpleConfigs.Examples - Contain using examples. Depends on all other assemblies in project exept SimpleConfigs.Test.

<div id="SimpleConfigs.Test"></div>

SimpleConfigs.Test - Contain tests for all other assemblies. Depends on all other assemblies in project exept SimpleConfigs.Examples.

Using

For example, you have config class like this:

public class MainConfig
{
	public string SomeUrl = "http://www.example.com/";
	public int SomeValue = 456;
}

To save this config as file, or populate this object with data from file, you should use ConfigsService class. It takes ISerializationManager as the first parameter. You can implement ISerializationManager interface by yourself or use an existing assembly, for example we take SimpleConfigs.JSON assembly and his ISerializationManager implementation JsonSerializationManager

Configs registration example:

// your function....

// registering config type must have at least one parameterless constructor!
var configsService = new ConfigsService(
	new JsonSerializationManager(), // ISerializationManager
	new LocalFileSystem(), // IFileSystem
	typeof(MainConfig) // registering config type
	);
	
// this method will create config files that not exist now
// and then load all existing config files data to configs instances.
await configsService.InitializeAllConfigsAsync(); 
// now you can get data from config file
var mainConfigInstance = configsService.GetConfig<MainConfig>();
Console.WriteLine($"{mainConfigInstance.SomeValue}"); // 456

// change it (this example work only if config type is referenced type)
mainConfigInstance.SomeValue = 15;

// and save to file
await configsService.SaveConfigToFileAsync<MainConfig>();

You can specify config file relative directory path via RelativePathAttribute. If you don't specify an attribute for the config type, the default file folder will be the folder of your running assembly.

// config file will be generated in "running assembly folder"/Configs/Main
[RelativePath("Configs/Main")] 
public class MainConfig 
{
	// your fields 
}

Also you can specify config file name via ConfigNameAttribute. If you don't specify it, the default file name will be: "Type name" + ".cfg"

// config file will have path:
// "running assembly folder"/Configs/Main/MyConfigName.myFileExtension
[RelativePath("Configs/Main"), ConfigName("MyConfigName.myFileExtension")]
public class MainConfig 
{
	// your fields 
}

And you can override all path data above using ConfigsService.SetPathOverrideSettings method.

// config file will have path:
// "running assembly folder"/Configs/Overrided/MyConfigName.myFileExtension
configsService.SetPathOverrideSettings<MainConfig>(
	new PathSettings("Configs/Overrided", "MyConfigName.myFileExtension"));

// config file will have path:
// "running assembly folder"/"default MainConfig filename"
configsService.SetPathOverrideSettings<MainConfig>(
	new PathSettings(null, ""));

Common information

<div id="ISerializationManager"></div>

ISerializationManager - This interface is responsible for converting config object data into a byte array that's will be written to a file. The implementation of this interface is not included in the main SimpleConfigs assembly to avoid creating unnecessary dependencies. You can implement this interface by yourself or use an existing assembly, for example: SimpleConfigs.JSON.

Product Compatible and additional computed target framework versions.
.NET 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SimpleConfigs:

Package Downloads
SimpleConfigs.JSON

Extension for SimpleConfigs package. Give you abbility to easy create, read and update config files in json format. Documentation: https://github.com/DanyloSih/SimpleConfigs

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.1 226 3/31/2024
1.2.0 222 3/31/2024
1.1.1 179 3/27/2024
1.1.0 205 3/27/2024
1.0.0 218 3/12/2024