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
<PackageReference Include="OutWit.Common.MEF" Version="1.1.0" />
<PackageVersion Include="OutWit.Common.MEF" Version="1.1.0" />
<PackageReference Include="OutWit.Common.MEF" />
paket add OutWit.Common.MEF --version 1.1.0
#r "nuget: OutWit.Common.MEF, 1.1.0"
#:package OutWit.Common.MEF@1.1.0
#addin nuget:?package=OutWit.Common.MEF&version=1.1.0
#tool nuget:?package=OutWit.Common.MEF&version=1.1.0
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 | Versions 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. |
-
net6.0
- OutWit.Common (>= 1.2.3)
- System.ComponentModel.Composition (>= 8.0.0)
-
net7.0
- OutWit.Common (>= 1.2.3)
- System.ComponentModel.Composition (>= 8.0.0)
-
net8.0
- OutWit.Common (>= 1.2.3)
- System.ComponentModel.Composition (>= 9.0.7)
-
net9.0
- OutWit.Common (>= 1.2.3)
- System.ComponentModel.Composition (>= 9.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.