Skip to content

Wallsmedia/DotNet.ServiceProvider.Locator

Repository files navigation

DotNet.Di.ServiceProvider.Locator

Static Dependency Injection service provider locator for complex web/plain applications.

https://www.nuget.org/packages/DotNet.ServiceProvider.Locator

Example for Rest Web API application:

public void Configure(IApplicationBuilder app)
{
 ...

 // Register as default
 ServiceProviderLocator.RegisterServiceProvider(app.ApplicationServices);

...
}

or 

public void Configure(IApplicationBuilder app)
{
...

// Register with name default

string name = "WebHostAppServices";
ServiceProviderLocator.RegisterServiceProvider(app.ApplicationServices,name);

...
}

Example for a plain application:

   ServiceCollection collection = new ServiceCollection();
   // Setup collection of the services

   // Register provider with locator
   ServiceProvider provider = collection.BuildServiceProvider();
   ServiceProviderLocator.RegisterServiceProvider(provider);

About

Dot NET Dependency Injection ServiceProvider Locator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages