Beispiel #1
0
        static void Main(string[] args)
        {
            //A hid  minta bevezetesehez es tesztjehez
            //TestBridge1();

            //Fel kell parameterezni a Ninject-et:
            kernel = new StandardKernel(); //A Ninject osztalya
            kernel.Bind <IPersonRepository>()
            //.To<PersonRepositoryTestData>() //Igy lehet valtani, hogy melyik repo-t hasznaljuk
            .To <PersonRepositorySimpleData>() //Igy lehet valtani, hogy melyik repo-t hasznaljuk

            .InSingletonScope();               //Csak egy peldanyban letezhet

            //Console.WriteLine("\n############################         ##################################\n");
            //A decorator/proxy/facade
            //TestBridgeDecoratorAndProxy();

            //plugin, ami elkuldi majd a leveleket:
            //var send = AbstractSendWith.Factory<SendWithExchange>();
            //var service = new EmailService(send);
            //var repo = kernel.Get<IPersonRepository>();
            //var template = new Templating();

            //var msgService = new MessageService(service, repo, template);

            //A fenitek helyett a letrehozasokat becsomagoljuk egy specialis strategiaba, majd
            //a strategiapeldanyt atadjuk a szerviznek hasznalatra.

            var birthdayMessageFactoryWithExchange = new BirthdayMessageFactoryWithExchange();
            var msgService = new MessageService(birthdayMessageFactoryWithExchange);

            msgService.Run();

            Console.WriteLine("\n############################         ##################################\n");
            var welcomeMessageFactoryWithSendGrid = new WelcomeMessageFactoryWithSendGrid();

            msgService = new MessageService(welcomeMessageFactoryWithSendGrid);

            msgService.Run();

            Console.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //A híd minta bevezetéséhez és tesztjéhez
            //TestBridge1();

            //Fel kell paraméterezni a Ninject-et:
            kernel = new StandardKernel();
            kernel.Bind <IPersonRepository>()
            //.To<PersonRepositoryTestData>()
            .To <PersonRepositorySimpleData>()
            .InSingletonScope();

            //Console.WriteLine();
            //Console.WriteLine("++++++++ +++++++++++++ +++++++++++++++++");
            //Console.WriteLine();

            //A dekorátor/proxy/facade
            //TestBridgeAndDecoratorAndProxy();

            //A létrehozásokat becsomagoljuk egy speciális stratégiába, majd
            //a stratégiapéldányt átadjuk a szervíznek használatra.

            var birthdayMessageFactoryWithExchange = new BirthdayMessageFactoryWithExchange();
            var msgService = new MessageService(birthdayMessageFactoryWithExchange);

            msgService.Run();

            //Console.WriteLine();
            //Console.WriteLine("++++++++ +++++++++++++ +++++++++++++++++");
            //Console.WriteLine();

            var factory = new WelcomeMessageFactoryWithSendGrid();

            msgService = new MessageService(factory);

            msgService.Run();
            Console.ReadLine();
        }