コード例 #1
0
        private void AddBindings()
        {
            // put bindings here

            //Mock<IProductRepository> mock = new Mock<IProductRepository>();
            //mock.Setup(m => m.Products).Returns(new List<Product>
            //{
            //    new Product { Name = "Football", Price = 25 },
            //    new Product { Name = "Surf board", Price = 179 },
            //    new Product { Name = "Running shoes", Price = 95 }
            //});
            //kernel.Bind<IProductRepository>().ToConstant(mock.Object);

            kernel.Bind<IProductRepository>().To<MongoProductRepository>();

            kernel.Bind<IUserRepository>().To<MongoUserRepository>();

            EmailSettings emailSettings = new EmailSettings
            {
                WriteAsFile = bool.Parse(ConfigurationManager.AppSettings["Email.WriteAsFile"] ?? "false")
            };

            kernel.Bind<IOrderProcessor>().To<EmailOrderProcessor>().WithConstructorArgument("settings", emailSettings);

            kernel.Bind<IAuthProvider>().To<BcryptAuthProvider>();
        }
コード例 #2
0
 public EmailOrderProcessor(EmailSettings settings)
 {
     emailSettings = settings;
 }
コード例 #3
0
 public EmailOrderProcessor(EmailSettings emailSettings)
 {
     _emailSettings = emailSettings;
 }