Looking for a way to initialize IOptions<T> manually?

public class ValueController : Controller
{
public ValueController(IOptions<AppSettings> options)
{
}
}
{
“AppSettings”: {
“SettingOne”: “ValueOne”
}
}
var settings = new AppSettings { SettingOne = “ValueOne” };
var obj = new ValueController(settings);
var settings = (IOptions<AppSettings>) new AppSettings { SettingOne = “ValueOne” };
var obj = new ValueController(settings);
var settings = Options.Create(new AppSettings { SettingOne = “ValueOne” });
var obj = new ValueController(settings);

--

--

--

Full stack developer | .Net Geek

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Top 6 most impactful features of Salesforce Spring ’22 release for Sales Cloud Lightning

The role of “EthSign Community Advocate”, what is it?

My Journey to Become a Staff Software Engineer

Building more predictable Kubernetes workloads with Helm & Kustomize

Helm ship navigating waters

3 Top-Notch Cloud Service Schedulers

Breaking down technical tasks with Atomic Planning

Manual Testing Tools for QA Engineers

7 Free Cloud Hosting Service Providers for Software Developers

Servers

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mahesh More

Mahesh More

Full stack developer | .Net Geek

More from Medium

How to use better GroupBy in LINQ ?

Optimistic Concurrency in Code First Entity Framework Core

C# Programming Language: Hashtables

Creating a ASP.NET Core Web API in .NET 6 with NUXT 3 (Template)