Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kurnakovv/genericenvironment
GenericEnvironment is generic System.Environment class library.
https://github.com/kurnakovv/genericenvironment
csharp nuget
Last synced: about 2 months ago
JSON representation
GenericEnvironment is generic System.Environment class library.
- Host: GitHub
- URL: https://github.com/kurnakovv/genericenvironment
- Owner: kurnakovv
- License: mit
- Created: 2023-05-30T11:36:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-02T04:58:41.000Z (over 1 year ago)
- Last Synced: 2024-04-28T09:31:30.749Z (9 months ago)
- Topics: csharp, nuget
- Language: C#
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: ReadMe.md
- License: LICENSE
Awesome Lists containing this project
README
GenericEnvironment
[![NuGet](https://img.shields.io/nuget/v/Kurnakov.GenericEnvironment.svg)](https://www.nuget.org/packages/Kurnakov.GenericEnvironment)
[![NuGet download](https://img.shields.io/nuget/dt/Kurnakov.GenericEnvironment.svg)](https://www.nuget.org/packages/Kurnakov.GenericEnvironment)
![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2FKurnakovMaksim%GenericEnvironment&countColor=%23263759&style=flat)
[![Build/Test](https://github.com/KurnakovMaksim/GenericEnvironment/actions/workflows/dotnet.yml/badge.svg)](https://github.com/KurnakovMaksim/GenericEnvironment/actions/workflows/dotnet.yml)
[![Codecov](https://codecov.io/gh/kurnakovv/GenericEnvironment/branch/main/graph/badge.svg)](https://codecov.io/gh/kurnakovv/GenericEnvironment)# Description
GenericEnvironment is generic System.Environment class library.
# How is it work
Environment variables
``` json
..."environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"YourIntVariable": "12345",
"YourBoolVariable": "true",
"YourStringVariable": "YourStringVariable"
...
}...
```Get variables with strict types
``` cs
int yourIntVariable = GenericEnvironment.GetEnvironmentVariable("YourIntVariable");
bool yourBoolVariable = GenericEnvironment.GetEnvironmentVariable("YourBoolVariable");
string yourStringVariable = GenericEnvironment.GetEnvironmentVariable("YourStringVariable");// Output
// yourIntVariable - 12345
// yourBoolVariable - true
// yourStringVariable - "YourStringVariable"
```Exceptions
``` cs
GenericEnvironment.GetEnvironmentVariable(null); // ArgumentNullException because name parameter is null.
GenericEnvironment.GetEnvironmentVariable("InvalidName"); // InvalidOperationException because variable not found by name.
GenericEnvironment.GetEnvironmentVariable("YourBoolVariable"); // InvalidCastException because type is nullable (bool?)
GenericEnvironment.GetEnvironmentVariable("YourIntVariable"); // FormatException because cannot convert variable to type (bool -> int)
```# Full docs
* [GenericEnvironment.GetEnvironmentVariable](DocsReadMe.md#genericenvironmentgetenvironmentvariable)
* [GenericEnvironment.TryGetEnvironmentVariable](DocsReadMe.md#genericenvironmenttrygetenvironmentvariable)
* [GenericEnvironment.GetEnvironmentVariableOrDefault](DocsReadMe.md#genericenvironmentgetenvironmentvariableordefault)# Reason
C# is a strictly typed language and I want to work environment variables as strictly typed variables. This library solves this problem.# Give a star ⭐
I hope this library is useful for you, if so please give a star for this repository, thank you :)