com.protostream.nuget.env 1.0.0

dotnet add package com.protostream.nuget.env --version 1.0.0                
NuGet\Install-Package com.protostream.nuget.env -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="com.protostream.nuget.env" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add com.protostream.nuget.env --version 1.0.0                
#r "nuget: com.protostream.nuget.env, 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.
// Install com.protostream.nuget.env as a Cake Addin
#addin nuget:?package=com.protostream.nuget.env&version=1.0.0

// Install com.protostream.nuget.env as a Cake Tool
#tool nuget:?package=com.protostream.nuget.env&version=1.0.0                

CEnvironment NuGet Package

CEnvironment is a utility package for .NET applications that simplifies reading configuration values from environment variables or a local JSON configuration file. This package allows you to set a local JSON file as a backup configuration source, helping streamline application setup.

Features

  • Retrieve configuration values from environment variables or a local JSON file.
  • Convert configuration values to different types: string, bool, int, and double.
  • Ideal for managing app settings in development and production environments.

Installation

Install via NuGet Package Manager:

dotnet add package com.protostream.nuget.env

Or in Visual Studio:

  1. Go to Project > Manage NuGet Packages...
  2. Search for com.protostream.nuget.env.
  3. Install the package.

Usage

1. Set a Local Configuration File

To use a local JSON file as a fallback configuration source, set the path using SetLocalConfig.

using com.protostream.nuget.env;

CEnvironment.SetLocalConfig("path/to/config.json");

2. Retrieve Values

CEnvironment provides methods to get values as various types.

string? value = CEnvironment.GetValue("MyKey");
bool isEnabled = CEnvironment.GetBool("IsEnabled");
int retryCount = CEnvironment.GetInt("RetryCount");
double threshold = CEnvironment.GetDouble("Threshold");

Example JSON Configuration File

In the JSON file, define keys and values as follows:

{
  "MyKey": "SomeValue",
  "IsEnabled": "true",
  "RetryCount": "5",
  "Threshold": "0.75"
}

Methods

  • SetLocalConfig(string path): Sets the path for the local JSON file.
  • GetValue(string key): Retrieves the value as a string.
  • GetBool(string key): Retrieves the value as a boolean.
  • GetInt(string key): Retrieves the value as an integer.
  • GetDouble(string key): Retrieves the value as a double.

License

This package is licensed under the MIT License.

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • 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 165 10/14/2024