static void Main(string[] args) { EFRepository<Product> productRepository = new EFRepository<Product>(); LoggingRepositoryDecorator<Product> updateDeleteLoggingDecorator = new LoggingRepositoryDecorator<Product>(productRepository); SendRequestRepositoryDecorator<Product> updateDeleteRequestDecorator = new SendRequestRepositoryDecorator<Product>(updateDeleteLoggingDecorator); UpdateDataWareHouseRepositoryDecorator<Product> updateDataWareHouseDecorator = new UpdateDataWareHouseRepositoryDecorator<Product>(updateDeleteRequestDecorator); SecurityRepositoryDecorator<Product> securityDecorator = new SecurityRepositoryDecorator<Product>(updateDataWareHouseDecorator); #region Select işlemi Console.WriteLine("--------------------------------------------"); securityDecorator.Get(3); Console.WriteLine("---------------------------------------------\n"); #endregion #region Add işlemi Console.WriteLine("--------------------------------------------"); Product p=new Product(){ ProductId=1, ProductName="Ürünüm 1" }; securityDecorator.Add(p); Console.WriteLine("---------------------------------------------\n"); #endregion #region Update ve Delete İşlemi Console.WriteLine("---------------------------------------------"); securityDecorator.Delete(p); Console.WriteLine("---------------------------------------------\n"); Console.WriteLine("---------------------------------------------"); securityDecorator.Update(p); Console.WriteLine("---------------------------------------------\n"); #endregion Console.ReadLine(); }
static void Main(string[] args) { EFRepository <Product> productRepository = new EFRepository <Product>(); LoggingRepositoryDecorator <Product> updateDeleteLoggingDecorator = new LoggingRepositoryDecorator <Product>(productRepository); SendRequestRepositoryDecorator <Product> updateDeleteRequestDecorator = new SendRequestRepositoryDecorator <Product>(updateDeleteLoggingDecorator); UpdateDataWareHouseRepositoryDecorator <Product> updateDataWareHouseDecorator = new UpdateDataWareHouseRepositoryDecorator <Product>(updateDeleteRequestDecorator); SecurityRepositoryDecorator <Product> securityDecorator = new SecurityRepositoryDecorator <Product>(updateDataWareHouseDecorator); #region Select işlemi Console.WriteLine("--------------------------------------------"); securityDecorator.Get(3); Console.WriteLine("---------------------------------------------\n"); #endregion #region Add işlemi Console.WriteLine("--------------------------------------------"); Product p = new Product() { ProductId = 1, ProductName = "Ürünüm 1" }; securityDecorator.Add(p); Console.WriteLine("---------------------------------------------\n"); #endregion #region Update ve Delete İşlemi Console.WriteLine("---------------------------------------------"); securityDecorator.Delete(p); Console.WriteLine("---------------------------------------------\n"); Console.WriteLine("---------------------------------------------"); securityDecorator.Update(p); Console.WriteLine("---------------------------------------------\n"); #endregion Console.ReadLine(); }
static void Main(string[] args) { #region Basics of Decorator Pattern Console.WriteLine("AppDatagram"); AppDatagram appDatagram = new AppDatagram(); appDatagram.Send(); Console.WriteLine("\nUseTCP"); Console.WriteLine("****************"); UseTCP useTCP = new UseTCP(appDatagram); useTCP.Send(); Console.WriteLine("\nUseUDP"); Console.WriteLine("****************"); UseUDP useUDP = new UseUDP(appDatagram); useUDP.Send(); #endregion Console.WriteLine( "\n" + "---------------------------------------------------------------\n" + "---------------------------------------------------------------\n" + "---------------------------------------------------------------\n" + "---------------------------------------------------------------\n"); #region Decorator Pattern in Repository Pattern Console.WriteLine("Repository"); Repository <Employee> repository = new Repository <Employee>(); repository.Get(3); repository.GetAll(); repository.Add(new Employee()); repository.Delete(new Employee()); repository.Update(new Employee()); Console.WriteLine("\nSecurityRepositoryDecorator"); Console.WriteLine("****************"); SecurityRepositoryDecorator <Employee> securityRepositoryDecorator = new SecurityRepositoryDecorator <Employee>(repository); securityRepositoryDecorator.Get(3); securityRepositoryDecorator.GetAll(); securityRepositoryDecorator.Add(new Employee()); securityRepositoryDecorator.Delete(new Employee()); securityRepositoryDecorator.Update(new Employee()); Console.WriteLine("\nLoggingRepositoryDecorator"); Console.WriteLine("****************"); LoggingRepositoryDecorator <Employee> loggingRepositoryDecorator = new LoggingRepositoryDecorator <Employee>(repository); loggingRepositoryDecorator.Get(3); loggingRepositoryDecorator.GetAll(); loggingRepositoryDecorator.Add(new Employee()); loggingRepositoryDecorator.Delete(new Employee()); loggingRepositoryDecorator.Update(new Employee()); Console.WriteLine("\nSendCRMRepositoryDecorator"); Console.WriteLine("****************"); SendCRMRepositoryDecorator <Employee> sendCRMRepositoryDecorator = new SendCRMRepositoryDecorator <Employee>(repository); sendCRMRepositoryDecorator.Get(3); sendCRMRepositoryDecorator.GetAll(); sendCRMRepositoryDecorator.Add(new Employee()); sendCRMRepositoryDecorator.Delete(new Employee()); sendCRMRepositoryDecorator.Update(new Employee()); Console.WriteLine("\nSendMailRepositoryDecorator"); Console.WriteLine("****************"); SendMailRepositoryDecorator <Employee> sendMailRepositoryDecorator = new SendMailRepositoryDecorator <Employee>(repository); sendMailRepositoryDecorator.Get(3); sendMailRepositoryDecorator.GetAll(); sendMailRepositoryDecorator.Add(new Employee()); sendMailRepositoryDecorator.Delete(new Employee()); sendMailRepositoryDecorator.Update(new Employee()); #endregion }