Bridge pattern theory code : Bridge Pattern « Design Patterns « C# / CSharp Tutorial






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());
    }
}








28.11.Bridge Pattern
28.11.1.Bridge pattern theory code