Closed coredevsushant closed 5 years ago
You might just wanna read over the docs a little better. You can either pass the exact IConfiguration object into your ServiceRegistry, or assume that something else registers it and use it in any kind of Lambda registration
I wanted to call one static class in which I need to pass IConfiguration, which will get called on startup
static class stay in Infrastructure layer I don't want to add a reference in the main application
Startup.cs public void ConfigureContainer(ServiceRegistry services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.Scan(scan => { scan.TheCallingAssembly(); scan.WithDefaultConventions(); scan.SingleImplementationsOfInterface(); scan.LookForRegistries(); }); }
I don't want to add a reference to Infrastructure Layer into the main calling application (in this case its Web Application)
I need to pass IConfiguration object SomeRegistry class which stay in the Infrastructure Layer In the following code, I am always getting configuration as null
SomeStaticRepository.Initialize is a static class in which I am assigning values and in my requirement, I am going to call directly a static class.
SomeRegistry.cs public class SomeRegistry: ServiceRegistry { public SomeRegistry() { //.......Repo Layers DI registration Container container = new Container(this); IConfiguration configuration = container.TryGetInstance(); // I am always getting "null"
SomeStaticRepository.Initialize(configuration);
}
}