OutWit.Common.MEF 1.1.0

dotnet add package OutWit.Common.MEF --version 1.1.0
                    
NuGet\Install-Package OutWit.Common.MEF -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OutWit.Common.MEF" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OutWit.Common.MEF" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="OutWit.Common.MEF" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OutWit.Common.MEF --version 1.1.0
                    
#r "nuget: OutWit.Common.MEF, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OutWit.Common.MEF@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OutWit.Common.MEF&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=OutWit.Common.MEF&version=1.1.0
                    
Install as a Cake Tool

OutWit.Common.MEF

OutWit.Common.MEF is a helper library that provides a seamless bridge between the OutWit.Common ecosystem and Microsoft's Managed Extensibility Framework (MEF).

This project allows you to leverage MEF's powerful composition and extensibility features, such as attribute-based dependency injection ([Import], [Export]), with components and models built using the OutWit.Common library.

✨ Key Features

  • Seamless Integration: Connects OutWit.Common components to the MEF composition container.
  • Promote Extensibility: Simplifies the creation of modular, plugin-based applications where different modules can discover and interact with each other.
  • Simplified DI: Use MEF to automatically satisfy dependencies for your OutWit.Common services and models.
  • Modern .NET Support: Multi-targeted for .NET 6, 7, 8, and 9.

🚀 Getting Started

1. Installation

Install the package from NuGet into your host application or relevant modules.

dotnet add package OutWit.Common.MEF

2. Dependencies

This library relies on two main packages:

  • OutWit.Common: The core library providing base models and services.

  • System.ComponentModel.Composition: The official package for the Managed Extensibility Framework (MEF).

3. Conceptual Usage

The primary goal is to allow parts of your application to be composed at runtime. For example, you can [Export] a service in one module and [Import] it in another without a direct compile-time reference.

Example: Exporting a Service

In one of your modules, you might define a service and export it using MEF's [Export] attribute.

C#

// In MyServiceModule.csproj
// <PackageReference Include="OutWit.Common.MEF" />

using System.ComponentModel.Composition;
using OutWit.Common.Services; // Assuming a base interface from OutWit.Common

[Export(typeof(IMyService))]
public class MyServiceImpl : IMyService
{
    public void PerformAction(string data)
    {
        // ... implementation ...
    }
}
Example: Importing and Using a Service

In your main application or another module, you can compose the parts and import the service where needed.

// In MainApp.csproj
// <PackageReference Include="OutWit.Common.MEF" />

using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using OutWit.Common.Services;

public class MainViewModel
{
    [Import]
    private IMyService _myService; // MEF will inject this

    public MainViewModel()
    {
        Compose();
    }

    private void Compose()
    {
        // Create a catalog of parts from your application's assemblies
        var catalog = new AggregateCatalog();
        catalog.Catalogs.Add(new AssemblyCatalog(typeof(MainViewModel).Assembly));
        // Add other assemblies or directories containing parts
        // catalog.Catalogs.Add(new DirectoryCatalog("./modules"));
        
        var container = new CompositionContainer(catalog);
        container.ComposeParts(this);
    }
    
    public void DoSomething()
    {
        // _myService is now a valid instance of MyServiceImpl
        _myService.PerformAction("Hello MEF!");
    }
}

This library provides the necessary glue and potentially custom MEF catalogs or helpers to make this integration with OutWit.Common components straightforward.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 54 8/1/2025
1.0.0 121 10/13/2024