Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var client = new DnsClient();

            var log = new Log();

            var config = ServiceConfigurationReader.Read();
            
            var container = new Container(new DependencyRegistry(config));

            var smtpServerSessionConfiguration = new SmtpServerSessionConfiguration
                {
                    TempDirectory = config.TempDirectory
                };

            Func<ISession> smtpSessionFactory = () => 
                new SmtpServerSession(new SmtpServerCommandHandler(container), log, smtpServerSessionConfiguration);

            var serverConfiguration = new ServerConfiguration()
                {
                    Port = 25
                };

            var smtpServer = new Server(smtpSessionFactory, log, serverConfiguration);
            var smtpRunTask = smtpServer.RunAsync();

            Func<ISession> pop3SessionFactory = () =>
             new Pop3ServerSession(new Pop3ServerCommandHandler(container), log, new Pop3ServerSessionConfiguration());

            var pop3ServerConfiguration = new ServerConfiguration()
                {
                    Port = 110
                };



            var deliverer = new MessageDeliverer(container);
            var delivererTask = deliverer.RunAsync();





            var pop3Server = new Server(pop3SessionFactory, log, pop3ServerConfiguration);
            var pop3RunTask = pop3Server.RunAsync();

            log.LogApplicationInfo("Server running...");


            Console.WriteLine("Press any key to exit");
            Console.ReadLine();

            log.LogApplicationInfo("Shutting down");

            var smtpStopTask = smtpServer.StopAsync();
            var pop3StopTask = pop3Server.StopAsync();

        }