Link copied to clipboard!
Adapter
Convert interface of adaptee to target interface needed by client.
C#
interface ITarget
{
string Get();
}
class Legacy
{
public string Fetch()
{
return "legacy";
}
}
class AdapterImpl : ITarget
{
private readonly Legacy _l;
public AdapterImpl(Legacy l)
{
_l = l;
}
public string Get()
{
return _l.Fetch();
}
}
ITarget t = new AdapterImpl(new Legacy());
string v = t.Get(); // legacy
next