Exemplo n.º 1
0
    static void Main()
    {
        Car car = new Car
        {
            Make  = "Scion",
            Model = "xD",
            Year  = 2010
        };

        Mechanic mechanic = new Mechanic();
        // Inject the dependency to Mechanic into the constructor
        AutoShop shop = new AutoShop(mechanic);

        shop.FixCar(car);

        Welder welder = new Welder();

        // Inject the dependency to Welder into the constructor
        shop = new AutoShop(welder);
        shop.FixCar(car);

        shop = new AutoShop();
        // Inject the dependency to Welder into the property
        shop.Worker = welder;
        shop.WeldCar(car);
    }
Exemplo n.º 2
0
    static void Main()
    {
        AutoShop shop = new AutoShop();
        Car      car  = new Car
        {
            Make  = "Scion",
            Model = "xD",
            Year  = 2010
        };

        shop.FixCar(car);
    }
Exemplo n.º 3
0
    static void Main()
    {
        Car car = new Car
        {
            Make  = "Scion",
            Model = "xD",
            Year  = 2010
        };

        Mechanic mechanic = new Mechanic();
        AutoShop shop     = new AutoShop(mechanic);

        shop.FixCar(car);

        Welder welder = new Welder();

        shop = new AutoShop(welder);
        shop.FixCar(car);
    }