Adapter Pattern - Composition (Source Code) NuGet Package

The provided ComposedAdapterService exports the IAdapterService interface, and "imports many" IAdapter implementations.

Initialize your composition container so that it contains both the exported adapters and the adapter service, and it
will be initialized automatically for use.

======= Example =======
// Initialize container with your assemblies/types/catalogs
CompositionContainer container = new CompositionContainer(catalog);

// Retrieve initialized adapter service
IAdapterService service = container.GetExportedValue<IAdapterService>();

// Initialize the adapter facade with the service
Adapters.SetService(service);

// Use adapter extension method As as needed, i.e.


// say we need to use it as an MSBuild project, if possible
IMSBuildProject msbuild = project.As<IMSBuildProject>();
if (msbuild != null)
// do MSBuild stuff with it.

======= Adapters =======
[Export(typeof(IAdapter))]
public class ProjectToMsBuildAdapter : IAdapter<IProject, IMSBuildProject>
{
// Implement actual conversion.
}

Simply by exporting the right contract, the adapter service will locate it.
Note that to create adapter implementations, you need to install the Adapter.Sdk package.




Got any Adapter Pattern - Composition (Source Code) Question?





Info

Version: 1.1.1301.1418
Author(s): Daniel Cazzulino
Last Update: Monday, January 14, 2013
.NET Fiddle: Create the first Fiddle
Project Url: https://github.org/clariuslabs/adapter
NuGet Url: https://www.nuget.org/packages/Adapter.Composition.Source


Install
Install-Package Adapter.Composition.Source
dotnet add package Adapter.Composition.Source
paket add Adapter.Composition.Source
Adapter.Composition.Source Download (Unzip the "nupkg" after downloading)



Tags



STATS

must-have-score

.5

avg-downloads-per-day

1

days-since-last-release

4113