Exemplo n.º 1
0
        private static void LoggerTest()
        {
            // MessageService messageService = new MessageService();

            MessageService messageService  = LazySingleton <MessageService> .Instance;
            MessageService messageService2 = LazySingleton <MessageService> .Instance;

            if (ReferenceEquals(messageService, messageService2))
            {
            }

            PrintService printService = new PrintService();

            messageService.Send("Hello World!");
            printService.Print("Hello World!", 3);

            if (ReferenceEquals(messageService.logger, printService.logger))
            {
                Console.WriteLine("The same instances");
            }
            else
            {
                Console.WriteLine("Different instances");
            }
        }
        private static void LoggerTest()
        {
            MessageService messageService = new MessageService();
            PrintService   printService   = new PrintService();

            messageService.Send("Hello World!");
            printService.Print("Hello World!", 3);

            if (ReferenceEquals(messageService.logger, printService.logger))
            {
                Console.WriteLine("The same instances");
            }
            else
            {
                Console.WriteLine("Different instances");
            }
        }