-
Couldn't load subscription status.
- Fork 5.2k
Provide System.Composition.TypedParts package readme #106785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+89
−7
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
src/libraries/System.Composition.TypedParts/src/PACKAGE.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| ## About | ||
|
|
||
| <!-- A description of the package and where one can find more documentation --> | ||
|
|
||
| `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 | ||
|
|
||
| <!-- The key features of this package --> | ||
|
|
||
| * Provides container configuration. | ||
|
|
||
| ## 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 --> | ||
|
|
||
| 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<IHandler>(); | ||
| 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 in this library --> | ||
|
|
||
| The main types provided by this library are: | ||
|
|
||
| * `System.Composition.Hosting.ContainerConfiguration` | ||
| * `System.Composition.CompositionContextExtensions` | ||
|
|
||
| ## Additional Documentation | ||
|
|
||
| <!-- Links to further documentation. Remove conceptual documentation if not available for the library. --> | ||
|
|
||
| * [Managed Extensibility Framework (MEF)](https://learn.microsoft.com/dotnet/framework/mef/) | ||
|
|
||
| ## Related Packages | ||
|
|
||
| <!-- The related packages associated with this package --> | ||
|
|
||
| * [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 | ||
|
|
||
| <!-- How to provide feedback on this package and contribute to it --> | ||
|
|
||
| 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). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.