Personal tools
Document Actions

Adaptation

RSS Feed Category: Infrastructure — Other products by this author
Adapter registry and lookup for .NET.

Current release: Adaptation 1.0.0

Released 2007-07-01 — tested with .NET 2.0

Production 1.0.0 release of Adaptation. This release is feature-complete.

List all releases… Full release announcement…

Get Adaptation for Windows (48.5 kB)

Adaptation 1.0.0 (Source release)

Get Adaptation for Windows (5.0 kB)

Adaptation 1.0.0 (Binary, Debug Build)

Get Adaptation for Windows (4.8 kB)

Adaptation 1.0.0 (Binary, Release Build)

Experimental releases

Upcoming and alpha/beta/candidate releases

  • Alpha releases should only be used for testing and development.
  • Beta releases and Release Candidates are normally released for production testing, but should not be used on mission-critical sites.
  • Always install on a separate test server first, and make sure you have proper backups before installing.

Release roadmap for Adaptation…

Adaptation 0.0.2 (Alpha release) Released 2007-06-25
Initial release. Provides basic adaptation registration and lookup functionality for .NET.

Project Description

Project resources

The adapter pattern is used to 'adapt' an interface provided by a class to one that a consuming pattern can use.

This software implements a registry where adapters can be registered to provide an interface given one or more context objects.

This allows smaller, simpler components.

Typical usage might be as follows:

// Register our adapters
registry.Register(typeof(IEvent), typeof(IHTMLDisplay), typeof(EventHtmlAdapter));
registry.Register(typeof(IImage), typeof(IHTMLDisplay), typeof(ImageHtmlAdapter));
registry.Register(typeof(INewsItem), typeof(IHTMLDisplay), typeof(NewsHtmlAdapter));

// Create our basic objects

// implements IEvent
Event ev = new Event();

// implements INewsItem
NewsItem news = new NewsItem();

// Implements IImage
Image im = new Image();

// Use a SimpleLookup for basic lookup policies
SimpleLookup lookup = new SimpleLookup(registry);
IHTMLDisplay adapter;
foreach(object ob in new object[] { ev, news, im })
{
adapter = lookup.AdaptTo<IHTMLDisplay>(ob);
System.Console.WriteLine(adapter.HTML);
}

// Actually, you can register and lookup by class too,
// not just interface
registry = new Registry();
registry.Register(typeof(Event), typeof(IHTMLDisplay), typeof(EventHtmlAdapter));
registry.Register(typeof(Image), typeof(IHTMLDisplay), typeof(ImageHtmlAdapter));
registry.Register(typeof(NewsItem), typeof(IHTMLDisplay), typeof(NewsHtmlAdapter));
lookup = new SimpleLookup(registry);

// This prints the same output as last time
foreach(object ob in new object[] { ev, news, im })
{
adapter = lookup.AdaptTo<IHTMLDisplay>(ob);
System.Console.WriteLine(adapter.HTML);
}

Self-Certification

[ ] Internationalized

[X] Unit tests

[ ] End-user documentation

[ ] Internal documentation (documentation, interfaces, etc.)

[ ] Existed and maintained for at least 6 months

[ ] Installs and uninstalls cleanly

[ ] Code structure follows best practice

Independent Review

by Dan Fairs last modified 2007-07-23 13:51

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: