コード例 #1
0
        private void AddBindings()
        {
            // Mock implementation of the IProductRepository Interface
            //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 } }.AsQueryable());
            ninjectKernel.Bind<IProductRepository>().To<EFProductRepository>();

            EmailSettings emailSettings = new EmailSettings
            {

            //         we specified a value for
            //only one of the EmailSettings properties: WriteAsFile. We read the value of this property using the
            //ConfigurationManager.AppSettings property, which allows us to access application settings we’ve
            //placed in the Web.config file (the one in the root project folder)

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

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

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