Microsoft.Extensions.DependencyInjection 8.0.0-rc.2.23479.6
About
Supports the dependency injection (DI) software design pattern which is a technique for achieving Inversion of Control (IoC) between classes and their dependencies.
Key Features
Provides an implementation of the DI interfaces found in the Microsoft.Extensions.DependencyInjection.Abstractions package.
How to Use
ServiceCollection services = new ();
services.AddSingleton<IMessageWriter, MessageWriter>();
using ServiceProvider provider = services.BuildServiceProvider();
// The code below, following the IoC pattern, is typically only aware of the IMessageWriter interface, not the implementation.
IMessageWriter messageWriter = provider.GetService<IMessageWriter>()!;
messageWriter.Write("Hello");
public interface IMessageWriter
{
void Write(string message);
}
internal class MessageWriter : IMessageWriter
{
public void Write(string message)
{
Console.WriteLine($"MessageWriter.Write(message: \"{message}\")");
}
}
Main Types
The main types provided by this library are:
Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactoryMicrosoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensionsMicrosoft.Extensions.DependencyInjection.ServiceProvider
Additional Documentation
- Conceptual documentation
- API documentation
Related Packages
Microsoft.Extensions.DependencyInjection.AbstractionsMicrosoft.Extensions.HostingMicrosoft.Extensions.Options
Feedback & Contributing
Microsoft.Extensions.DependencyInjection is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Showing the top 20 packages that depend on Microsoft.Extensions.DependencyInjection.
| Packages | Downloads |
|---|---|
|
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
When using NuGet 3.x this package requires at least version 3.4.
|
9 |
|
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
|
8 |
|
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
|
7 |
https://go.microsoft.com/fwlink/?LinkID=799421
.NET Framework 4.6.2
- Microsoft.Bcl.AsyncInterfaces (>= 8.0.0-rc.2.23479.6)
- System.Threading.Tasks.Extensions (>= 4.5.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0-rc.2.23479.6)
.NET Standard 2.1
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0-rc.2.23479.6)
.NET Standard 2.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0-rc.2.23479.6)
- Microsoft.Bcl.AsyncInterfaces (>= 8.0.0-rc.2.23479.6)
- System.Threading.Tasks.Extensions (>= 4.5.4)
.NET 8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0-rc.2.23479.6)
.NET 6.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0-rc.2.23479.6)
.NET 7.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0-rc.2.23479.6)