appsettings in console application c#
C#
{
"SomeKey": "This is from Config!"
}
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.3" />
</ItemGroup>
public Startup()
{
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{environment}.json", optional: true)
.AddEnvironmentVariables()
.Build();
}
using System;
using Microsoft.Extensions.Configuration;
namespace DiConsoleApp
{
public class SomeService : ISomeService
{
IConfiguration configuration;
public SomeService(IConfiguration configuration)
{
this.configuration = configuration;
}
public void DoProcess()
{
var value = configuration["SomeKey"];
Console.WriteLine("Value from the Config is: " + value);
}
}
}
Also in C#:
- Title
- json serialize object capitalization config
- Category
- C#
- Title
- leantween move ui
- Category
- C#
- Title
- scaffold-dbcontext sql server
- Category
- C#
- Title
- unity t-flip flop
- Category
- C#
- Title
- unity connect to firebase
- Category
- C#
- Title
- how to create a variable in C#
- Category
- C#
- Title
- how to detected WindowCloseEvent in other window wpf
- Category
- C#
- Title
- datatable return column names
- Category
- C#
- Title
- create line in unity
- Category
- C#
- Title
- how to make % posibility to spawn an object C# in unity
- Category
- C#
- Title
- interpolate rotation unity3d
- Category
- C#
- Title
- create object in c#
- Category
- C#
- Title
- vb.net tostring numeric format string
- Category
- C#
- Title
- how to go to other forms in C#
- Category
- C#
- Title
- variables
- Category
- C#
- Title
- c# odd even median
- Category
- C#
- Title
- how to flip selection in aseprite
- Category
- C#
- Title
- c# print expression tree
- Category
- C#
- Title
- unity get all by tag
- Category
- C#
- Title
- check distance to gameobject
- Category
- C#
- Title
- c# contextswitchdeadlock
- Category
- C#
- Title
- unity if gameobject exists
- Category
- C#
- Title
- unity custom update
- Category
- C#
- Title
- Instantiate c#
- Category
- C#
- Title
- make a list c#
- Category
- C#
- Title
- unity main texture not working
- Category
- C#
- Title
- get day month year from date c#
- Category
- C#
- Title
- comments unity c#
- Category
- C#
- Title
- import regex c#
- Category
- C#
- Title
- how to convert string to bool c#
- Category
- C#
- Title
- unity button interactable
- Category
- C#
- Title
- how to move towards an object unity
- Category
- C#
- Title
- c# check to see if dictionary key exists
- Category
- C#
- Title
- c# request run as administrator
- Category
- C#
- Title
- null coalesce ternary c#
- Category
- C#
- Title
- c# counting lines
- Category
- C#
- Title
- uncaught syntaxerror invalid or unexpected token unity webgl
- Category
- C#
- Title
- Exception thrown: 'System.FormatException' in mscorlib.dll dates
- Category
- C#
- Title
- if and c#
- Category
- C#
- Title
- letter at index of string c#
- Category
- C#
- Title
- c# enum.getvalues
- Category
- C#
- Title
- c# resize bitmap
- Category
- C#
- Title
- how to import datagridview to datatable in c#
- Category
- C#
- Title
- wpf c# select folder path
- Category
- C#
- Title
- c# error "The name 'ViewBag' does not exist in the current context"
- Category
- C#
- Title
- c# abstract class
- Category
- C#
- Title
- c# rsa example
- Category
- C#
- Title
- c sharp index of substring
- Category
- C#
- Title
- c# public static string
- Category
- C#
- Title
- wpf get name of clicked element
- Category
- C#
- Title
- read in multiple numbers c#
- Category
- C#
- Title
- wpf binding object get value
- Category
- C#
- Title
- convert string to datetime c#
- Category
- C#
- Title
- how to reference scripts in other scenes unity
- Category
- C#
- Title
- abstract class c#
- Category
- C#
- Title
- show double in textbox c#
- Category
- C#
- Title
- dontdestroyonload unity
- Category
- C#
- Title
- stop ui from clipping wall
- Category
- C#
- Title
- toggle unity c#
- Category
- C#
- Title
- c# ?
- Category
- C#
- Title
- c# shorten an definition
- Category
- C#
- Title
- C# int to hex
- Category
- C#
- Title
- system.io.directorynotfoundexception c#
- Category
- C#
- Title
- c# check if type implements interface
- Category
- C#
- Title
- C# get all child classes of a class
- Category
- C#
- Title
- winforms timer c#
- Category
- C#
- Title
- remove items from list c# condition
- Category
- C#
- Title
- download and run exe c# 1 button
- Category
- C#
- Title
- json tiers dot in name c#
- Category
- C#
- Title
- debug.log unity
- Category
- C#
- Title
- newtonsoft create dynamic object
- Category
- C#
- Title
- font family behind code uwp c#
- Category
- C#
- Title
- define enum c#
- Category
- C#
- Title
- internal c#
- Category
- C#
- Title
- how to check if an integer is in array c#
- Category
- C#
- Title
- unity find object by name
- Category
- C#
- Title
- unity movetowards 2d
- Category
- C#
- Title
- visual studio c# mark class deprecated
- Category
- C#
- Title
- computer
- Category
- C#
- Title
- linq foreach c#
- Category
- C#
- Title
- Unity C# add slider into editor
- Category
- C#
- Title
- html hidden text
- Category
- C#
- Title
- c# filesystemwatcher double events
- Category
- C#
- Title
- console application in c# ms crm
- Category
- C#
- Title
- c# bitmap to Image
- Category
- C#
- Title
- c# creating exceptions
- Category
- C#
- Title
- c# find duplicates in list
- Category
- C#
- Title
- string to enum c#
- Category
- C#
- Title
- wpf restart application c#
- Category
- C#
- Title
- how to track a branch on github
- Category
- C#
- Title
- c# while loop
- Category
- C#
- Title
- start a particle effect when a button is pushed
- Category
- C#
- Title
- built in methods to order a list c#
- Category
- C#
- Title
- linq c# object except two lists
- Category
- C#
- Title
- how to clear console through script unity
- Category
- C#
- Title
- unity deactivate scripts in list
- Category
- C#
- Title
- unity onselect gizmos wireframe
- Category
- C#
- Title
- c# replace string case insensitive
- Category
- C#
- Title
- unity mobile controls
- Category
- C#
- Title
- c# skip following code in loop
- Category
- C#