Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // Run code for Interface Polymorphism
            var encoder = new VideoEncoder();

            //Polymorphic dispatch
            encoder.RegisterNotificationChannel(new MailNotificationChannel());
            encoder.RegisterNotificationChannel(new SMSNotificationChannel());
            encoder.Encode(new Video());

            //Run code for Extensibility
            //var dbMigrator = new DbMigrator(new ConsoleLogger());
            //dbMigrator.Migrate();

            //Console.ForegroundColor = ConsoleColor.White;

            // The behaviour of the app is changed by extending the app,
            // instead of changing the existing code. (OCP)
            // Here the extension point is, use of an interface
            var dbMigratorFileLogging = new DbMigrator(new FileLogger("e:\\log.txt"));

            dbMigratorFileLogging.Migrate();

            //Run code for Testability
            //var orderProcessor = new OrderProcessor(new ShippingCalculator());
            //var order = new Order { DatePlaced = DateTime.Now, TotalPrice = 100f };
            //orderProcessor.Process(order);
        }
Ejemplo n.º 2
0
        static void Main()
        {
            var encoder = new VideoEncoder();

            encoder.RegisterNotificationChannel(new MailNotificationChannel());
            encoder.RegisterNotificationChannel(new SmsNotificationChannel());
            encoder.Encode(new Video());
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            //InterfaceViaPolymorphism

            var videoEncoder = new VideoEncoder();

            videoEncoder.RegisterNotificationChannel(new MailNotificationChannel());
            videoEncoder.RegisterNotificationChannel(new SmsNotificationChannel());
            videoEncoder.Encode();


            //OCP
            //var dbMigrator = new DbMigrator(new ConsoleLogger());
            var dbMigrator = new DbMigrator(new FileLogger(@"C:\Study\file.txt"));

            dbMigrator.Migrate();

            //OrderProcessor
            var order = new Order
            {
                TotalPrice = 20f,
                DatePlaced = DateTime.Now
            };
            var orderProcssor = new OrderProcessor(new ShippingCalculator());

            orderProcssor.Process(order);
            var user = new User
            {
                Status = RegistrationStatus.Active,
                Type   = UserType.Admin
            };

            if (user.Type == UserType.Admin && user.Status == RegistrationStatus.Active)
            {
                Console.WriteLine("Login Successfull...");
            }
        }