Example #1
0
        private void Init()
        {
            if (IocContainer.Instance.Kernel.HasComponent(typeof(IDependencyProvider)))
            {
                return;
            }
            CommonFrameworkBuilder.Initialize();
            CommonFrameworkBuilder.AddAssembly <IBaseDependency>(Assembly.GetExecutingAssembly());
            CommonFrameworkBuilder.AddEfService()
            .SetConnectionStringProvider(m => ConnectionStringProviderExtensions.GetWebConfigConnectionString(m), "WebAPIDemoEntities");
            CommonFrameworkBuilder.AddEmailService()
            .Config(cfg => cfg.setHost("smtp.126.com").setSenderAddress("*****@*****.**").setEmailSenderName("shengxupeng").setEmailPwd("999").setKey("aaa"))
            .Config(cfg => cfg.setHost("smtp.exmail.qq.com").setSenderAddress("*****@*****.**").setEmailSenderName("shengxupeng").setEmailPwd("9999").setKey("bbb").isDefault());

            CommonFrameworkBuilder.AddLog4Net().Configure("Log.xml");

            CommonFrameworkBuilder.AddDtoService(mapper =>
            {
                mapper.CreateMap <DtoSourceClass, DtoDestinationClass>()
                .ForMember(opt => opt.DestinationName, opt => opt.MapFrom(s => s.Name + "?" + s.SourceId));
                mapper.CreateMap <UserInfo, UserDto>()
                .ForMember(m => m.UserDtoId, m => m.MapFrom(s => s.Id))
                .ForMember(m => m.UserDtoName, m => m.MapFrom(s => s.Id + s.Name));
            }
                                                 ,
                                                 "CommonFramework.Core", "CommonFramework.CastleWindsor.Test");
            //var _connStr = IocContainer.Instance.Resolve<IConnectionStringProvider>();
            //_connStr.SetConnectionStringProvider(m=>_connStr.GetWebConfigConnectionString(m), "WebAPIDemoEntities");
            //var _email = IocContainer.Instance.Resolve<IEmailConfiguration>();
            //_email.Config(cfg=>cfg.setHost("smtp.126.com").setSenderAddress("*****@*****.**").setEmailSenderName("shengxupeng").setEmailPwd("999").setKey("aaa"));
            //_email.Config(cfg => cfg.setHost("smtp.exmail.qq.com").setSenderAddress("*****@*****.**").setEmailSenderName("shengxupeng").setEmailPwd("9999").setKey("bbb").isDefault());
        }
        private void Init()
        {
            var container = IocContainer.Instance;

            //if (container.IsRegistered(typeof(ITestService)))
            //    return;
            CommonFrameworkBuilder.Initialize();
            CommonFrameworkBuilder.AddAssembly <IBaseDependency>(Assembly.GetExecutingAssembly());
            CommonFrameworkBuilder.AddEfService()
            .SetConnectionStringProvider(m => ConnectionStringProviderExtensions.GetAppConfigConnectionString(m), "WebAPIDemoEntities");
            CommonFrameworkBuilder.AddEmailService()
            .Config(cfg => cfg.setHost("smtp.126.com").setSenderAddress("*****@*****.**").setEmailSenderName("shengxupeng").setEmailPwd("999").setKey("aaa"))
            .Config(cfg => cfg.setHost("smtp.exmail.qq.com").setSenderAddress("*****@*****.**").setEmailSenderName("shengxupeng").setEmailPwd("9999").setKey("bbb").isDefault());

            CommonFrameworkBuilder.AddLog4Net().Configure("Log.xml");

            //UnityBuilderExtensions.AddUnity();
            //var app = IocContainer.Instance.Resolve<IAppBuilder>();
            //app.AddAssembly<IBaseDependency>(Assembly.GetExecutingAssembly());
            //app.AddEfService()
            //    .SetConnectionStringProvider(m => ConnectionStringProviderExtensions.GetAppConfigConnectionString(m), "WebAPIDemoEntities");
            //app.AddEmailService()
            //    .Config(cfg => cfg.setHost("smtp.126.com").setSenderAddress("*****@*****.**").setEmailSenderName("shengxupeng").setEmailPwd("999").setKey("aaa"))
            //    .Config(cfg => cfg.setHost("smtp.exmail.qq.com").setSenderAddress("*****@*****.**").setEmailSenderName("shengxupeng").setEmailPwd("9999").setKey("bbb").isDefault());
        }
Example #3
0
        private void Init()
        {
            if (IocContainer.Instance.Kernel.HasComponent(typeof(IDependencyProvider)))
            {
                return;
            }
            CommonFrameworkBuilder.Initialize();
            CommonFrameworkBuilder.AddAssembly <IBaseDependency>(Assembly.GetExecutingAssembly());
            CommonFrameworkBuilder.AddEfService()
            .SetConnectionStringProvider(m => ConnectionStringProviderExtensions.GetWebConfigConnectionString(m), "testdatabaseEntities");
            CommonFrameworkBuilder.AddEmailService()
            .Config(cfg => cfg.setHost("smtp.126.com").setSenderAddress("*****@*****.**").setEmailSenderName("shengxupeng").setEmailPwd("999").setKey("aaa"))
            .Config(cfg => cfg.setHost("smtp.exmail.qq.com").setSenderAddress("*****@*****.**").setEmailSenderName("shengxupeng").setEmailPwd("9999").setKey("bbb").isDefault());

            CommonFrameworkBuilder.AddLog4Net().Configure("Log.xml");
        }