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); }
static void Main(string[] args) { // var dbMigrator = new DbMigrator(new ConsoleLogger()); var dbMigrator = new DbMigrator(new FileLogger("/Users/jjohns944/Documents/Other/dotnet/intermediate-csharp/Interfaces/log.txt")); dbMigrator.Migrate(); }
static void Main(string[] args) { var dbMigrator = new DbMigrator(new ConsoleLogger()); var dbMigrator2 = new DbMigrator(new FileLogger("C:\\Users\\crist\\OneDrive\\Desktop\\log.txt")); dbMigrator.Migrate(); dbMigrator2.Migrate(); Console.Read(); }
static void Main(string[] args) { //Interfaces and Testability //var orderProcessor = new OrderProcessor( new ShippingCalculator()); //var order = new Order { DatePlaced = DateTime.Now, TotalPrice = 100f }; //orderProcessor.Process(order); //Interfaces and extensibility //var dbMigrator = new DbMigrator(new ConsoleLogger()); var dbMigrator = new DbMigrator(new FileLogger("C:\\Projects\\log.txt")); dbMigrator.Migrate(); Console.ReadLine(); }
static void Main(string[] args) { //Lesson 10 : Interfaces //10.1 - General //var shape = new Shape(); //Circle circle = new Circle(shape); //circle.Draw(); //10.2 - Extensibility - Dependency Injection example //ex1 var dbmigrator = new DbMigrator(new ConsoleLogger()); dbmigrator.Migrate(); //ex2 // in xxx put your file path var dbmigrator2 = new DbMigrator(new FileLogger(@"xxx\xxx.txt")); dbmigrator2.Migrate(); }
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..."); } }
static void Main(string[] args) { var dbMigrator = new DbMigrator(new ConsoleLogger()); dbMigrator.Migrate(); }