diff --git a/src/libraries/System.Composition.TypedParts/src/PACKAGE.md b/src/libraries/System.Composition.TypedParts/src/PACKAGE.md new file mode 100644 index 0000000000000..de02f4525c866 --- /dev/null +++ b/src/libraries/System.Composition.TypedParts/src/PACKAGE.md @@ -0,0 +1,88 @@ +## About + + + +`System.Composition.TypedParts` is part of the Managed Extensibility Framework (MEF) 2.0, a composition library for .NET that enables dependency injection through attributes or conventions. + +Provides `ContainerConfiguration` and some extension methods for the Managed Extensibility Framework (MEF). + +## Key Features + + + +* Provides container configuration. + +## How to Use + + + +Register parts from an entire assembly. + +```csharp +using System.Composition; +using System.Composition.Hosting; +using System.Reflection; + +// Register all parts from the current assembly +var configuration = new ContainerConfiguration() + .WithAssembly(Assembly.GetExecutingAssembly()); + +using CompositionHost container = configuration.CreateContainer(); + +var handlers = container.GetExports(); +foreach (var handler in handlers) +{ + handler.Handle(); +} +// HandlerA is handling. +// HandlerB is handling. + +public interface IHandler +{ + void Handle(); +} + +[Export(typeof(IHandler))] +public class HandlerA : IHandler +{ + public void Handle() => Console.WriteLine("HandlerA is handling."); +} + +[Export(typeof(IHandler))] +public class HandlerB : IHandler +{ + public void Handle() => Console.WriteLine("HandlerB is handling."); +} +``` + +## Main Types + + + +The main types provided by this library are: + +* `System.Composition.Hosting.ContainerConfiguration` +* `System.Composition.CompositionContextExtensions` + +## Additional Documentation + + + +* [Managed Extensibility Framework (MEF)](https://learn.microsoft.com/dotnet/framework/mef/) + +## Related Packages + + + +* [System.Composition](https://www.nuget.org/packages/System.Composition) +* [System.Composition.AttributedModel](https://www.nuget.org/packages/System.Composition.AttributedModel) +* [System.Composition.Convention](https://www.nuget.org/packages/System.Composition.Convention) +* [System.Composition.Hosting](https://www.nuget.org/packages/System.Composition.Hosting) +* [System.Composition.Runtime](https://www.nuget.org/packages/System.Composition.Runtime) + +## Feedback & Contributing + + + +System.Composition.TypedParts 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). diff --git a/src/libraries/System.Composition.TypedParts/src/System.Composition.TypedParts.csproj b/src/libraries/System.Composition.TypedParts/src/System.Composition.TypedParts.csproj index 4e82792a39994..3a2874d9d3f0b 100644 --- a/src/libraries/System.Composition.TypedParts/src/System.Composition.TypedParts.csproj +++ b/src/libraries/System.Composition.TypedParts/src/System.Composition.TypedParts.csproj @@ -8,16 +8,10 @@ Microsoft false true - Provides some extension methods for the Managed Extensibility Framework. - -Commonly Used Types: -System.Composition.CompositionContextExtensions -System.Composition.Hosting.ContainerConfiguration + Provides container configuration and some extension methods for the Managed Extensibility Framework (MEF). disable $(NoWarn);nullable - - false