Created
December 29, 2011 15:41
-
-
Save rbwestmoreland/1534639 to your computer and use it in GitHub Desktop.
Properly Implementing the Adapter Pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
/// <summary> | |
/// The actual interface. | |
/// </summary> | |
public interface IActual | |
{ | |
void Process(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
/// <summary> | |
/// The expected interface. | |
/// </summary> | |
public interface IExpected | |
{ | |
void DoWork(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment