System.Composition.TypedParts (9.0.0)

Published 2026-09-09 02:37:05 +03:30 by kayer

Installation

dotnet nuget add source --name kayer --username your_username --password your_token 
dotnet add package --source kayer --version 9.0.0 System.Composition.TypedParts

About this package

Provides container configuration and some extension methods for the Managed Extensibility Framework (MEF).

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.

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 by this library are:

  • System.Composition.Hosting.ContainerConfiguration
  • System.Composition.CompositionContextExtensions

Additional Documentation

Feedback & Contributing

System.Composition.TypedParts is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Dependencies

ID Version Target Framework
System.Composition.AttributedModel 9.0.0 .NETFramework4.6.2
System.Composition.Hosting 9.0.0 .NETFramework4.6.2
System.Composition.Runtime 9.0.0 .NETFramework4.6.2
System.Composition.AttributedModel 9.0.0 .NETStandard2.0
System.Composition.Hosting 9.0.0 .NETStandard2.0
System.Composition.Runtime 9.0.0 .NETStandard2.0
System.Composition.AttributedModel 9.0.0 net8.0
System.Composition.Hosting 9.0.0 net8.0
System.Composition.Runtime 9.0.0 net8.0
System.Composition.AttributedModel 9.0.0 net9.0
System.Composition.Hosting 9.0.0 net9.0
System.Composition.Runtime 9.0.0 net9.0
Details
NuGet
2026-09-09 02:37:05 +03:30
8
Microsoft
178 KiB
Assets (2)
Versions (2) View all
9.0.0 2026-09-09
7.0.0 2026-02-04