Example #1
0
        static void Main(string[] args)
        {
            #region  LiskovSubstitution

            Duck duck = DuckFactory.GetDuck(DuckType.Muscovy);
            duck.Move();
            duck.Quark();
            while (duck.Weight < 10)
            {
                duck.Eat();
            }

            #endregion

            #region LeastKnowledge

            var    unfriendlyStaff = new UnfriendlyStaff();
            Doctor doctor          = unfriendlyStaff.GetAvailableDoctor(DateTime.Today);
            doctor.BookTimeByPhone(DateTime.Today);

            var friendlyStaff = new FriendlyStaff();
            friendlyStaff.BookDoctor(DateTime.Today);

            #endregion

            #region IoC

            var noIoC = new NoIoC();
            noIoC.Running();
            noIoC.RidingBike();
            noIoC.Swimming();

            var injectByConstructor = new InjectByConstructor(new Sprint(), new RideRoadBike(), new FreeStyleSwim());
            injectByConstructor.Running();
            injectByConstructor.RidingBike();

            var injectBySetter = new InjectBySetter();
            injectBySetter.Run      = new Sprint();
            injectBySetter.RideBike = new RideRoadBike();
            injectByConstructor.Running();
            injectByConstructor.RidingBike();

            #endregion


            Console.ReadKey();
        }