コード例 #1
0
        public void Print()
        {
            // Lớp ConcreteDependency sử dụng trực tiếp lớp HP Printer
            HPPrinter worker = new HPPrinter();

            worker.Print();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: mt26691/learning-solid
        static void Main(string[] args)
        {
            Console.WriteLine("This is concrete Dependency");
            ConcreteDependency concreteDependency = new ConcreteDependency();

            concreteDependency.Print();

            Console.WriteLine("This is abstract Dependency");
            AbstractDependency abstractDependency = new AbstractDependency();
            IPrinter           hpPrinter          = new HPPrinter();
            IPrinter           canonPrinter       = new CanonPrinter();

            abstractDependency.Print(hpPrinter);
            abstractDependency.Print(canonPrinter);

            Console.ReadLine();
        }