Skip to content

Commit e288218

Browse files
eNeRGy164sirntar
authored andcommitted
Provide System.Composition.Hosting package readme (dotnet#106783)
* Provide System.Composition.Hosting package readme * Improve after feedback
1 parent 81c7857 commit e288218

File tree

2 files changed

+81
-6
lines changed

2 files changed

+81
-6
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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).

src/libraries/System.Composition.Hosting/src/System.Composition.Hosting.csproj

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,10 @@
77
<StrongNameKeyId>Microsoft</StrongNameKeyId>
88
<UseCompilerGeneratedDocXmlFile>false</UseCompilerGeneratedDocXmlFile>
99
<IsPackable>true</IsPackable>
10-
<PackageDescription>Provides Managed Extensibility Framework types that are useful to developers of extensible applications, or hosts.
11-
12-
Commonly Used Types:
13-
System.Composition.Hosting.CompositionHost</PackageDescription>
10+
<PackageDescription>Provides Managed Extensibility Framework (MEF) types that are useful to developers of extensible applications, or hosts.</PackageDescription>
1411
<!-- TODO https://github.com/dotnet/runtime/issues/90400: Annotate for nullable reference types -->
1512
<Nullable>disable</Nullable>
1613
<NoWarn>$(NoWarn);nullable</NoWarn>
17-
<!-- TODO: Add package README file: https://github.com/dotnet/runtime/issues/99358 -->
18-
<EnableDefaultPackageReadmeFile>false</EnableDefaultPackageReadmeFile>
1914
</PropertyGroup>
2015

2116
<ItemGroup>

0 commit comments

Comments
 (0)