❔ Options Pattern for injecting configuration
I have a class library (Infrastructure) which has code that injects services in the service container. I want to inject configuration from my appsettings.json using the options patterns and the scope of the class representing the config section (JwtTokenOptions) is limited to the class library. How can I do this? This is what I have done after reading from microsoft docs and it doesn't seem to work. Thanks.
https://learn.microsoft.com/en-us/dotnet/core/extensions/options#optionsbuilder-api
Options pattern - .NET
Learn how to use the options pattern to represent groups of related settings in .NET apps.
![](https://utfs.io/f/08c7b5a5-3859-4040-9b2b-3a7a1a2aa671-1sd4vx.png)
5 Replies
Maybe you are missing the Binder package?
![](https://utfs.io/f/46ff4fba-07d8-4b37-8779-5f8adf29e47a-1nq2cb.png)
or you can just do "Configure" like this:
![](https://utfs.io/f/c4bc6736-a1a8-4483-9eba-752c266d2768-1nq2cb.png)
then you just pull it in using IOptions<YourOptions> value
yup I was missing this package microsoft.extensions.options.configurationextensions Thanks! ![o7](https://cdn.discordapp.com/emojis/885720005294043199.png)
![o7](https://cdn.discordapp.com/emojis/885720005294043199.png)
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.