using System;
interface Action
{
string DoIt();
}
class Wrapper
{
Action action;
public Wrapper(Action implementation)
{
action = implementation;
}
public string Operation()
{
return action.DoIt();
}
}
class ImplementationA : Action
{
public string DoIt()
{
return "ImplementationA";
}
}
class ImplementationB : Action
{
public string DoIt()
{
return "ImplementationB";
}
}
class BridgePattern
{
static void Main()
{
Console.WriteLine(new Wrapper(new ImplementationA()).Operation());
Console.WriteLine(new Wrapper(new ImplementationB()).Operation());
}
}
|