I am developing an application using MVC6. I can read JSON configuration in Startup file and dependency inject it in the controllers.
Now, my requirements is that I want to access configuration inside classes that are not controllers. I can't use constructor DI in such cases. These classes reside in some folder of the MVC6 application but they are not model or controller classes.
What's the best way to access configuration in such non-controller classes?
Thank you.
UPDATE:
Just to clarify - I can't use DI with these classes.
These classes are instantiated only when needed based on some condition and methods are called on them. I need to access JSON config settings from within these classes/methods. So, far I know only these ways:
Make Configuration property from Startup as static so that I can say
Startup.Configuration["..."].Set static properties of a custom class from Startup after reading JSON config and then access those static properties.
Are these alternative good (other than DI of course)? Are there any other ways?