Add Microsoft.Extensions.DependencyInjection
authorSteve Harter <steveharter@users.noreply.github.com>
Thu, 7 Sep 2023 16:10:45 +0000 (11:10 -0500)
committerViktor Hofer <viktor.hofer@microsoft.com>
Mon, 18 Sep 2023 14:24:48 +0000 (16:24 +0200)
src/libraries/Microsoft.Extensions.DependencyInjection/src/PACKAGE.md

index dbf1973..5ebf199 100644 (file)
@@ -1,44 +1,50 @@
 ## About
-
-<!-- A description of the package and where one can find more documentation -->
-
-
+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
-
-<!-- The key features of this package -->
-
-*
-*
-*
+Provides an implementation of the DI interfaces found in the `Microsoft.Extensions.DependencyInjection.Abstractions` package.
 
 ## How to Use
-
-<!-- A compelling example on how to use this package with code, as well as any specific guidelines for when to use the package -->
+```cs
+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 in this library -->
-
 The main types provided by this library are:
-
-* ``
-* ``
-* ``
+* `Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory`
+* `Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions`
+* `Microsoft.Extensions.DependencyInjection.ServiceProvider`
 
 ## Additional Documentation
-
-<!-- Links to further documentation. Remove conceptual documentation if not available for the library. -->
-
-* [Conceptual documentation](https://learn.microsoft.com/en-us/dotnet/standard/serialization/**LIBRARYNAME**/overview)
-* [API documentation](https://learn.microsoft.com/en-us/dotnet/api/**LIBRARYNAME**)
+* [Conceptual documentation](https://learn.microsoft.com/dotnet/core/extensions/dependency-injection)
+* API documentation
+  - [DefaultServiceProviderFactory](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.defaultserviceproviderfactory)
+  - [ServiceCollectionContainerBuilderExtensions](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.servicecollectioncontainerbuilderextensions)
+  - [ServiceProvider](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.serviceprovider)  
 
 ## Related Packages
-
-<!-- The related packages associated with this package -->
+- `Microsoft.Extensions.DependencyInjection.Abstractions`
+- `Microsoft.Extensions.Hosting`
+- `Microsoft.Extensions.Options`
 
 ## Feedback & Contributing
-
-<!-- How to provide feedback on this package and contribute to it -->
-
-Microsoft.Extensions.DependencyInjection is released as open source under the [MIT license](https://licenses.nuget.org/MIT). Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/runtime).
\ No newline at end of file
+Microsoft.Extensions.DependencyInjection is released as open source under the [MIT license](https://licenses.nuget.org/MIT). Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/runtime).