| 
 | 1 | +## About  | 
 | 2 | + | 
 | 3 | +<!-- A description of the package and where one can find more documentation -->  | 
 | 4 | + | 
 | 5 | +`System.Composition.Hosting` is part of the Managed Extensibility Framework (MEF) 2.0, a composition library for .NET that enables dependency injection through attributes or conventions.  | 
 | 6 | + | 
 | 7 | +This package provides core services for creating composition containers.  | 
 | 8 | +It offers tools to configure and manage the composition of parts within your application, facilitating dependency injection and enabling modular architectures.  | 
 | 9 | + | 
 | 10 | +## Key Features  | 
 | 11 | + | 
 | 12 | +<!-- The key features of this package -->  | 
 | 13 | + | 
 | 14 | +* Create and manage composition containers for dynamic dependency injection.  | 
 | 15 | + | 
 | 16 | +## How to Use  | 
 | 17 | + | 
 | 18 | +<!-- A compelling example on how to use this package with code, as well as any specific guidelines for when to use the package -->  | 
 | 19 | + | 
 | 20 | +Create a composition host and compose parts.  | 
 | 21 | + | 
 | 22 | +```csharp  | 
 | 23 | +using System.Composition;  | 
 | 24 | +using System.Composition.Hosting;  | 
 | 25 | + | 
 | 26 | +// Create a container configuration  | 
 | 27 | +var configuration = new ContainerConfiguration()  | 
 | 28 | +    .WithPart<Service>();  | 
 | 29 | + | 
 | 30 | +// Create the composition host (container)  | 
 | 31 | +using CompositionHost container = configuration.CreateContainer();  | 
 | 32 | + | 
 | 33 | +// Get an instance of the service  | 
 | 34 | +var service = container.GetExport<IService>();  | 
 | 35 | +service.Run();  | 
 | 36 | +// Service is running!  | 
 | 37 | +
  | 
 | 38 | +public interface IService  | 
 | 39 | +{  | 
 | 40 | +    void Run();  | 
 | 41 | +}  | 
 | 42 | + | 
 | 43 | +[Export(typeof(IService))]  | 
 | 44 | +public class Service : IService  | 
 | 45 | +{  | 
 | 46 | +    public void Run() => Console.WriteLine("Service is running!");  | 
 | 47 | +}  | 
 | 48 | +```  | 
 | 49 | + | 
 | 50 | +## Main Types  | 
 | 51 | + | 
 | 52 | +<!-- The main types provided in this library -->  | 
 | 53 | + | 
 | 54 | +The main type provided by this library is:  | 
 | 55 | + | 
 | 56 | +* `System.Composition.CompositionHost`  | 
 | 57 | + | 
 | 58 | +## Additional Documentation  | 
 | 59 | + | 
 | 60 | +<!-- Links to further documentation. Remove conceptual documentation if not available for the library. -->  | 
 | 61 | + | 
 | 62 | +* [API documentation](https://learn.microsoft.com/dotnet/api/system.composition.hosting)  | 
 | 63 | +* [Managed Extensibility Framework (MEF)](https://learn.microsoft.com/dotnet/framework/mef/)  | 
 | 64 | + | 
 | 65 | +## Related Packages  | 
 | 66 | + | 
 | 67 | +<!-- The related packages associated with this package -->  | 
 | 68 | + | 
 | 69 | +* [System.Composition](https://www.nuget.org/packages/System.Composition)  | 
 | 70 | +* [System.Composition.AttributedModel](https://www.nuget.org/packages/System.Composition.AttributedModel)  | 
 | 71 | +* [System.Composition.Convention](https://www.nuget.org/packages/System.Composition.Convention)  | 
 | 72 | +* [System.Composition.Runtime](https://www.nuget.org/packages/System.Composition.Runtime)  | 
 | 73 | +* [System.Composition.TypedParts](https://www.nuget.org/packages/System.Composition.TypedParts)  | 
 | 74 | + | 
 | 75 | +## Feedback & Contributing  | 
 | 76 | + | 
 | 77 | +<!-- How to provide feedback on this package and contribute to it -->  | 
 | 78 | + | 
 | 79 | +System.Composition.Hosting is released as open source under the [MIT license](https://licenses.nuget.org/MIT).  | 
 | 80 | +Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/runtime).  | 
0 commit comments