public EmailMessage GetMessageFor(Person person)
        {
            var from = EmailAddressFactory.GetOfficeAddress();
            var to   = EmailAddressFactory.GetNewAddress(person.EmailAddress.Address, person.EmailAddress.Display);

            string subject = GetSubject(person);
            string message = GetMessage(person);

            return(EmailMessage.Factory(from, to, subject, message));
        }
Пример #2
0
        private static void TestBridge1()
        {
            EmailMessage message = EmailMessage.Factory(
                from: EmailAddressFactory.GetNewAddress(address: "*****@*****.**", display: "az elso cim"),
                to: EmailAddressFactory.GetNewAddress(address: "*****@*****.**", display: "a masodik cim"),
                subject: "tesztuzenet",
                message: "Ez egy tesztuzenet, amit egy kuld a kettonek.");
            ///////////////////////////////////////////

            //Concrete Implementor
            //var strategy = AbstractSendWith.Factory(SendWithTypes.SendWith);
            var strategy = AbstractSendWith.Factory <SendWith>(); //statikus fgv-t keszitettunk

            //abstraction
            var service = new EmailService(strategy);

            service.Send(message);
            Console.WriteLine();
            ///////////////////////////////////////////

            //Concrete Implementor
            //var strategyMsx = AbstractSendWith.Factory(SendWithTypes.SendWithExchange);
            var strategyMsx = AbstractSendWith.Factory <SendWithExchange>();

            //Nem kell uj service tipust peldanyositani!
            service = new EmailService(strategyMsx);
            service.Send(message);
            Console.WriteLine();
            ///////////////////////////////////////////

            //Concrete Implementor
            //var strategySG = AbstractSendWith.Factory(SendWithTypes.SendWithSendGrid);
            var strategySG = AbstractSendWith.Factory <SendWithSendGrid>();

            service = new EmailService(strategySG);
            service.Send(message);
            Console.WriteLine();
            ///////////////////////////////////////////

            //Concrete Implementor
            //var strategyM = AbstractSendWith.Factory(SendWithTypes.SendWithMandrill);
            var strategyM = AbstractSendWith.Factory <SendWithMandrill>();

            service = new EmailService(strategyM);
            service.Send(message);
            Console.WriteLine();
        }
Пример #3
0
        private static void TestBridge1()
        {
            EmailMessage message = EmailMessage.Factory(
                from: EmailAddressFactory.GetNewAddress(address: "*****@*****.**", display: "az első cím"),
                to: EmailAddressFactory.GetNewAddress(address: "*****@*****.**", display: "a második cím"),
                subject: "tesztüzenet",
                message: "ez egy tesztüzenet, amit egy küld a kettőnek");


            //Concrete implementor
            var strategy = AbstractSendWith.Factory <SendWith>();

            //Abstraction
            var service = new EmailService(strategy);

            service.Send(message);
            Console.WriteLine();

            //Concrete implementor
            var strategyMsx = AbstractSendWith.Factory <SendWithExchange>();

            //vegyük észre: nem kell új szerviz típust példányositani
            service = new EmailService(strategyMsx);
            service.Send(message);
            Console.WriteLine();
            //Concrete implementor
            var strategySG = AbstractSendWith.Factory <SendWithSendGrid>();

            service = new EmailService(strategySG);
            service.Send(message);
            Console.WriteLine();
            //Concrete implementor
            var strategyM = AbstractSendWith.Factory <SendWithMandrill>();

            service = new EmailService(strategyM);
            service.Send(message);
        }