Properly Implementing the Adapter Pattern
using System;
/// <summary>
/// The expected interface.
/// </summary>
public interface IExpected
{
void DoWork();
}
using System;
/// <summary>
/// The actual interface.
/// </summary>
public interface IActual
{
void Process();
}
using System;
/// <summary>
/// An actual to expected adapter.
/// <para>The Adapter pattern is a structural pattern,
/// whose purpose is to convert the interface of a class
/// into another interface clients expect.</para>
/// </summary>
public class ActualToExpectedAdapter : IExpected
{
private IActual Instance { get; set; }
public ActualToExpectedAdapter(IActual instance)
{
Instance = instance;
}
public void DoWork()
{
Instance.Process();
}
}