当前位置: 首页>>代码示例>>C#>>正文


C# EmailSettings类代码示例

本文整理汇总了C#中EmailSettings的典型用法代码示例。如果您正苦于以下问题:C# EmailSettings类的具体用法?C# EmailSettings怎么用?C# EmailSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EmailSettings类属于命名空间,在下文中一共展示了EmailSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddBindings

 private void AddBindings()
 {
     ninjectKernel.Bind<IProductRepository>().To<EFProductRepository>();
     EmailSettings emailSettings = new EmailSettings();
     ninjectKernel.Bind<IOrderProcessor>().To<EmailOrderProcessor>().WithConstructorArgument("settings", emailSettings);
     ninjectKernel.Bind<IAuthProvider>().To<FormsAuthProvider>();
 }
开发者ID:switch527,项目名称:SportsStore,代码行数:7,代码来源:NinjectControllerFactory.cs

示例2: AddBindings

 private void AddBindings() {
     kernel.Bind<IProductRepository>().To<EFProductRepository>();
     EmailSettings emailSettings = new EmailSettings {
         WriteAsFile = bool.Parse(ConfigurationManager.AppSettings["Email.WriteAsFile" ?? "false"])
     };
     kernel.Bind<IOrderProcessor>().To<EmailOrderProcessor>().WithConstructorArgument("settings", emailSettings);            
 }
开发者ID:Geronimobile,项目名称:DotNetExamIntro,代码行数:7,代码来源:NinjectDependencyResolver.cs

示例3: AddBindings

        private void AddBindings()
        {
            // add bindings here

            _kernel.Bind<IProductRepository>().To<EfProductRepository>();

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

            // pass the webconfig value to the constructor of the emailorderprocessor
            _kernel.Bind<IOrderProcessor>().To<EmailOrderProcessor>().WithConstructorArgument("settings", emailSettings);

            // when using IAuthProvider, call my custom authentication provider for forms
            _kernel.Bind<IAuthProvider>().To<FormsAuthProvider>();

            // mock repo
            //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}
            //    });

            // want Ninject to return the same mock object whenever it gets a request - a singleton (using .ToConstant())
            // _kernel.Bind<IProductRepository>().ToConstant(mock.Object);
        }
开发者ID:pixelsyndicate,项目名称:Pro_AspNet_MVC_5_book,代码行数:30,代码来源:NinjectDependencyResolver.cs

示例4: AddBingings

 private void AddBingings()
 {
     #region mock_object         
     //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>().ToConstant(mock.Object); 
     #endregion
     //EF
     ninjectKernel.Bind<IProductRepository>().To<EFProductRepository>();
     //EMAIL
     EmailSettings emailSettings = new EmailSettings
     {
         WriteAsFile = bool.Parse(ConfigurationManager
         .AppSettings["Email.WriteAsFile"] ?? "false")
     };
     ninjectKernel.Bind<IOrderProcessor>()
     .To<EmailOrderProcessor>()
     .WithConstructorArgument("settings", emailSettings);
     //AUTH
     ninjectKernel.Bind<IAuthProvider>().To<FormsAuthProvider>();
 }
开发者ID:horbel,项目名称:SportsStore,代码行数:25,代码来源:NinjectControllerFactory.cs

示例5: AddBindings

        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<EFProductRepository>();

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

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

            kernel.Bind<IAuthProvider>().To<FormsAuthProvider>();
        }
开发者ID:JakeRyu,项目名称:SportsStore,代码行数:25,代码来源:NinjectDepedencyResolver.cs

示例6: SendEmail

        public void SendEmail(EmailSettings settings, string subject, string body, bool htmlBody = false)
        {
            var email = new MailMessage();
            email.From = new MailAddress(settings.From);

            email.To.Add(settings.To);

            email.Subject = subject;
            email.Body = body;
            email.IsBodyHtml = htmlBody;

            NetworkCredential credentials = null;

            if (!string.IsNullOrWhiteSpace(settings.Username))
                credentials = new NetworkCredential(settings.Username, settings.Password);

            try
            {
                Send(email, settings.Server, settings.Port, settings.Ssl, credentials);
            }
            catch(Exception ex)
            {
                _logger.Error("Error sending email. Subject: {0}", email.Subject);
                _logger.Debug(ex, ex.Message);
                throw;
            }
        }
开发者ID:drewfreyling,项目名称:NzbDrone,代码行数:27,代码来源:EmailService.cs

示例7: AddBindings

        private void AddBindings()
        {
            // put additional bindings here
            var prods = new Product[] {
                new Product{ProductID =1, Name ="Mangos", Category="Fruit", Description="Summer gift", Price=12M},
                new Product{ProductID =2, Name ="Apples", Category="Fruit", Description="spring gift", Price=20M},
                new Product{ProductID =3, Name ="Nike Joggers", Category="Sports", Description="football fever", Price=13M},
                new Product{ProductID =4, Name ="Calculator", Category="Accounting", Description="japaniiii", Price=52M},
                new Product{ProductID =5, Name ="PC", Category="Computers", Description="I am PC", Price=92M},
                new Product{ProductID =6, Name ="MAC", Category="Computers", Description="I am  Mac", Price=120M}
            };

            //Mocking IProduct and setting what will its Products property will return
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(prods.AsQueryable());

            //Registering the Mock object with IProductRepository
            //ninjectKernel.Bind<IProductRepository>().ToConstant(mock.Object);
            ninjectKernel.Bind<IProductRepository>().To<EFProductRepository>();
            EmailSettings emailSettings = new EmailSettings
            {
                WriteAsFile
                = bool.Parse(ConfigurationManager.AppSettings["Email.WriteAsFile"] ?? "false")
            };
            ninjectKernel.Bind<IOrderProcessor>()
            .To<EmailOrderProcessor>().WithConstructorArgument("settings", emailSettings);

            ninjectKernel.Bind<IAuthProvider>().To<FormsAuthProvider>();
        }
开发者ID:najamsk,项目名称:SportsStore,代码行数:29,代码来源:NinjectControllerFactory.cs

示例8: Can_Send_Email

        public void Can_Send_Email() {

            // Arrange - create and populate a cart
            Cart cart = new Cart();
            cart.AddItem(new Product { ProductID = 1, Name = "Banana", Price = 10M }, 2);
            cart.AddItem(new Product { ProductID = 2, Name = "Apple", Price = 5M }, 2);

            // Arrange - create and populate some shipping details
            ShippingDetails shipDetails = new ShippingDetails {
                Name = "Joe Smith",
                Line1 = "Apartment 4a",
                Line2 = "123 West Street",
                City = "Northtown",
                State = "GA",
                Country = "USA",
                Zip = "12345"
            };

            // Arrange - create the test-specific email settings
            EmailSettings settings = new EmailSettings {
            
                // put test specific settings here
                WriteAsFile = true
            };

            // Arrange - create the EmailOrderProcessor class
            EmailOrderProcessor proc = new EmailOrderProcessor(settings);

            // Act - process the order
            proc.ProcessOrder(cart, shipDetails);

            // NOTE - there is assert in this test

        }
开发者ID:evkap,项目名称:AspNetMvcTestApp,代码行数:34,代码来源:EmailOrderProcessorTest.cs

示例9: EmailNotifier

        public EmailNotifier(EmailSettings settings)
        {
            Settings = settings;
            // test settings
            if (settings.ToFunction == null || settings.From == null || settings.Host == null || settings.SubjectFunction == null || settings.BodyFunction == null)
                throw new Exception("Please at least fill in the following settings: Host, From, ToFunction, SubjectFunction, BodyFunction");

            new SmtpClient(settings.Host, settings.Port ?? 25);
        }
开发者ID:BackseatDevelopers,项目名称:BLocal,代码行数:9,代码来源:EmailNotifier.cs

示例10: AddBindings

        private void AddBindings()
        {
            ninjectKernel.Bind<IProductRepository>().To<EFProductRepository>();

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

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

            ninjectKernel.Bind<IAuthProvider>().To<FormsAuthProvider>();
        }
开发者ID:jamesmaxwell,项目名称:SportsStore,代码行数:10,代码来源:NinjectControllerFactory.cs

示例11: AddBindings

 public void AddBindings()
 {
     kernel.Bind<IProductRepository>().To<EFProductRepository>();
     EmailSettings emailSettings = new EmailSettings
     {
         WriteAsFile = bool.Parse(ConfigurationManager.AppSettings["Email.WriteAsFile"] ?? "false")
     };
     kernel.Bind<IOrderProcessor>().To<InternetEmailOrderProcessor>().WithConstructorArgument("settings", emailSettings);
     kernel.Bind<IAuthProvider>().To<FormsAuthProvider>();
 }
开发者ID:brainiacOnly,项目名称:SportsStore,代码行数:10,代码来源:NinjectDependencyResolver.cs

示例12: AddBindings

        private void AddBindings()
        {
            // Mock implementation of the IProductRepository
            ninjectKernel.Bind<IProductRepository>().To<EFProductRepository>();

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

            ninjectKernel.Bind<IOrderProcessor>().To<EmailOrderProcessor>().WithConstructorArgument("settings", emailSettings);
        }
开发者ID:djandreski,项目名称:SportsStore,代码行数:10,代码来源:NinjectControllerFactory.cs

示例13: AddBindings

        private void AddBindings()
        {
            kernel.Bind<IProductRepository>().To<EFProductRepository>();

            EmailSettings emailSettings = new EmailSettings
            {
                WriteAsFile = bool.Parse(ConfigurationManager.AppSettings["Email.WriteAsFile"] ?? "false")//read the property
            };
            kernel.Bind<IOrderProcessor>().To<EmailOrderProcessor>()
            .WithConstructorArgument("settings", emailSettings);//create an EmailSettings object to intect into the EmailOrderProcessor Constructor

            kernel.Bind<IAuthProvider>().To<FormsAuthProvider>();
        }
开发者ID:yingliang33h,项目名称:SylviaSportsStore,代码行数:13,代码来源:NinjectDependencyResolver.cs

示例14: RegisterTypes

        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to 
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
            // container.LoadConfiguration();

            container.RegisterType<IProductRepository, SportsStore.Domain.Concrete.EFProductRepository>();
            EmailSettings emailSettings = new EmailSettings
            {
                WriteAsFile = bool.Parse(ConfigurationManager
.AppSettings["Email.WriteAsFile"] ?? "false")
            };
            container.RegisterType<IOrderProcessor, SportsStore.Domain.Concrete.EmailOrderProcessor>(new InjectionConstructor(emailSettings));
        }
开发者ID:GraySerg,项目名称:AspNetByAdamFreeman,代码行数:17,代码来源:UnityConfig.cs

示例15: AddBindings

        private void AddBindings()
        {
            // Здесь размещаются привязки Ninject
            kernel.Bind<IProductRepository>().To<EFProductRepository>();

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

            kernel.Bind<IOrderProcessor>().To<EmailOrderProcessor>()
                .WithConstructorArgument("settings",emailSettings);
            kernel.Bind<IAuthProvider>().To<FormsAuthProvider>();
        }
开发者ID:RadSt,项目名称:MVC5Site,代码行数:15,代码来源:NinjectDependencyResolver.cs


注:本文中的EmailSettings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。