Esempio n. 1
0
        private static IContainer CreateContainer(IAppConfiguration config)
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <ReseiptItemRepository>()
            .WithParameter("connectionFactory", new SqlConnectionFactory(config.ConnectionString("payment"))).AsImplementedInterfaces();
            builder.RegisterType <ReceiptsDbContext.Mapper>();

            //builder.RegisterType<FermaService>()
            //    .AsImplementedInterfaces()
            //    .SingleInstance();

            builder.RegisterType <CreateReceiptHandler>()
            .WithParameter("endpoint", config["FermaReceiptEndpoint"].AsString())
            .AsImplementedInterfaces();

            builder.RegisterType <GetTokenRestClient>()
            .WithParameter("endpoint", config["FermaAuthEndpoint"].AsString())
            .WithParameter("fermaLogin", config["FermaLogin"].AsString())
            .WithParameter("fermaPassword", config["FermaPassword"].AsString())
            .AsImplementedInterfaces();

            builder.RegisterType <GetReceiptsListRestClient>()
            .WithParameter("endpoint", config["FermaReceiptsListEndpoint"].AsString())
            .AsImplementedInterfaces();

            builder.RegisterType <GetReceiptStatusRestClient>()
            .WithParameter("endpoint", config["FermaStatusEndpoint"].AsString())
            .AsImplementedInterfaces();

            builder.RegisterType <CreateReceiptModule>();
            builder.RegisterType <SwaggerModule>();

            return(builder.Build());
        }
Esempio n. 2
0
        private static IContainer CreateContainer(IAppConfiguration config)
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <EmailItemRepository>()
            .WithParameter("connectionFactory", new SqlConnectionFactory(config.ConnectionString("email"))).AsImplementedInterfaces();
            builder.RegisterType <EmailItemsDbContext.Mapper>();

            builder.RegisterType <FakeSmtpClient>()
            .WithParameter("userName", config["FromAddress"].AsString())
            .WithParameter("password", config["Password"].AsString())
            .WithParameter("smtpHost", config["SmtpHost"].AsString())
            .WithParameter("smtpPort", config["SmtpPort"].AsInt())
            .AsImplementedInterfaces();

            builder.RegisterType <MailMessageFactory>()
            .WithParameter("fromAddress", config["FromAddress"].AsString())
            .WithParameter("fromDisplayName", config["FromDisplayName"].AsString())
            .AsImplementedInterfaces();

            builder.RegisterType <SendEmailModule>();
            builder.RegisterType <SendEmailHandler>();
            builder.RegisterType <SendEmailValidator>().AsImplementedInterfaces();
            builder.Register(c => new ValidatedCommandHandler <SendEmail>(c.Resolve <SendEmailHandler>(), c.Resolve <IValidator <SendEmail> >()))
            .AsImplementedInterfaces();

            builder.RegisterType <GetEmailItemModule>();
            builder.RegisterType <GetEmailItemHandler>().AsImplementedInterfaces();

            builder.RegisterType <SwaggerModule>();

            return(builder.Build());
        }