ConfigCreator.Framework 1.0.0

dotnet add package ConfigCreator.Framework --version 1.0.0
                    
NuGet\Install-Package ConfigCreator.Framework -Version 1.0.0
                    
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="ConfigCreator.Framework" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ConfigCreator.Framework" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ConfigCreator.Framework" />
                    
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 ConfigCreator.Framework --version 1.0.0
                    
#r "nuget: ConfigCreator.Framework, 1.0.0"
                    
#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 ConfigCreator.Framework@1.0.0
                    
#: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=ConfigCreator.Framework&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ConfigCreator.Framework&version=1.0.0
                    
Install as a Cake Tool

Config-Creator

A simple library for creating config files

There are two versions of this library:

Installing

NuGet\Install-Package ConfigCreator -Version 1.0.0

or

NuGet\Install-Package ConfigCreator.Framework -Version 1.0.0

Documentation | RU Language

Documentation Content:

Config.CreateConfigFile(string configFileName, string configPath)

This method creates a file with the items you added. Use only after the Config.Add method

configFileName - Config name

configPath - The path to the folder where the config will be located. Leave null if you want it to be saved in the same folder as the exe file

Example:

using ConfigCreator;

Config.Add("ApiKey", null, null); // Adding an item to the config
Config.Add("File", "default", null);
Config.Add("Language", "RU", "Languages: EN, RU, UA");
Config.CreateConfigFile("appsettings", null); // Creating a config file

Config.Add(string configItem, string itemValue, string configItemComment)

This method allows you to add an item to your config file, give it a comment and a default value

configItem - The name of the item in the config, example: [ConfigItem]

itemValue - The standard value for the item in the config file

configItemComment - Comment on the item in the config file

Example:

using ConfigCreator;

Config.Add("ApiKey", null, null); // Adding an item to the config
Config.Add("File", "default", null);
Config.Add("Language", "RU", "Languages: EN, RU, UA");
Config.CreateConfigFile("appsettings", null); // Creating a config file

The contents of this config file:

image

Config.Initialize(string configFileName, string configPath)

This method initializes the configuration to memory. It is recommended to run it every time you start the program so that your application does not throw an exception

configFileName - Config name

configPath - The path to the folder where the configuration is located. The path to the folder where the configuration is located. If the configuration file is in the same folder as the exe file of your program, then leave null

using ConfigCreator;

Config.Initialize("appsettings", null); // initializing config into memory
Console.WriteLine($"ApiKey: {Config.GetItem("ApiKey")}"); // display config value

Config.GetItem(string configItem)

This method will help you get the value from the config file. returns null if no value was found

configItem - Item in the config

Example:

using ConfigCreator;

Config.Initialize("appsettings", null); // initializing config into memory
Console.WriteLine($"ApiKey: {Config.GetItem("ApiKey")}"); // display config value

Config.getConfigPath()

Returns the path to the config after its initialization

Program example

using ConfigCreator;

Config.Add("ApiKey", null, null); // Adding items into config file
Config.Add("File", "default", null);
Config.Add("Language", "RU", "Languages: EN, RU, UA");
Config.CreateConfigFile("appsettings", null); // Creating config file
Config.Initialize("appsettings", null); // initializing config file into memory
Console.WriteLine($"Config path detected: {Config.getConfigPath()}");
if (Config.GetItem("ApiKey") == null)
{
    Console.WriteLine("ApiKey not found. Check if you have filled it out in the config");
    Console.ReadKey();
    return;
}
Console.WriteLine($"ApiKey: {Config.GetItem("ApiKey")}"); // displaying information
Console.WriteLine($"File: {Config.GetItem("File")}");
Console.WriteLine($"Language: {Config.GetItem("Language")}");
Console.ReadLine();

Output:

image

Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 343 12/10/2022