Beispiel #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var ambientDbLocater = new AmbientDbContextLocator();

            var container = new Container();
            container.Options.DefaultScopedLifestyle = new LifetimeScopeLifestyle();

            container.Register<IAmbientDbContextLocator, AmbientDbContextLocator>(Lifestyle.Singleton);
            container.Register<IUnitOfWork>(() => new EFUnitOfWork(), Lifestyle.Scoped);

            container.Register<IUnitOfWorkFactory>(
                () => new EFUnitOfWorkFactory(System.Data.IsolationLevel.ReadUncommitted));

            container.Register<IClienteRepository, ClienteRepository>();
            container.Register<IClientesService, ClientesService>();

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
Beispiel #2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            // Simple Injection Setup
            var container = new Container();

            // SI Controllers Dependency Injection
            container.Register<IUserHelper, UserHelper>(Lifestyle.Singleton);
            container.Register<IConfigurationHelper, ConfigurationHelper>(Lifestyle.Singleton);
            container.Register<IErrorSignaler, ErrorSignaler>(Lifestyle.Singleton);
            container.Register<IAddressResource, AddressResource>(Lifestyle.Singleton);
            container.Register<IHobbyResource, HobbyResource>(Lifestyle.Singleton);
            container.Register<IEducationResource, EducationResource>(Lifestyle.Singleton);
            container.Register<IUsersResource, UsersResource>(Lifestyle.Singleton);
            container.Register<IMediaResource, MediaResource>(Lifestyle.Singleton);
            container.Register<INotificationResource, NotificationResource>(Lifestyle.Singleton);

            // SI Token Identity Registers
            container.Register<IdentityDbContext<BlogUser>, BlogIdentityDbContext>(Lifestyle.Singleton);
            container.Register<IUserStore<BlogUser>, BlogUserStore>(Lifestyle.Singleton);
            container.Register<IBlogDbRepository, BlogDbRepository>(Lifestyle.Singleton);
            container.Register<BlogUserManager, BlogUserManager>(Lifestyle.Singleton);

            // SI Registrations
            container.RegisterMvcControllers(System.Reflection.Assembly.GetExecutingAssembly());
            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            // Register the dependency resolver.
            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
Beispiel #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Allow Any Certificates
            // This should not be the same in Production
            ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

            // Create the container as usual.
            var container = new Container();
            container.Options.PropertySelectionBehavior = new ImportPropertySelectionBehavior();
            container.Register<IErrorSignaler, ErrorSignaler>(Lifestyle.Singleton);
            container.Register<IHttpClientHelper, HttpClientHelper>(Lifestyle.Singleton);
            container.Register<IConfigurationHelper, ConfigurationHelper>(Lifestyle.Singleton);

            // SI Attributes Dependency Injection
            container.RegisterInitializer<BlogApiAuthorizationAttribute>(a => a.ErrorSignaler = container.GetInstance<ErrorSignaler>());
            container.RegisterInitializer<BlogAuthorizationAttribute>(a => a.ErrorSignaler = container.GetInstance<ErrorSignaler>());

            // This is an extension method from the integration package.
            container.RegisterMvcControllers(System.Reflection.Assembly.GetExecutingAssembly());
            container.RegisterMvcIntegratedFilterProvider();
            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjector.Integration.Web.Mvc.SimpleInjectorDependencyResolver(container));
        }
        public static void Configure(Container container)
        {
            container.RegisterMvcControllers(typeof(MvcConfig).Assembly);
            container.RegisterMvcIntegratedFilterProvider();

            RouteTable.Routes.MapMvcAttributeRoutes();
            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
Beispiel #5
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterWebApiFilters(GlobalConfiguration.Configuration.Filters);
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            FormatConfig.RegisterFormats(GlobalConfiguration.Configuration.Formatters);

            // Allow Any Certificates
            // This should not be the same in Production
            ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
            
            // Simple Injection Setup
            var container = new Container();
            container.Options.PropertySelectionBehavior = new ImportPropertySelectionBehavior();

            // SI Controllers registry
            container.Register<ICommentsResource, CommentsResource>(Lifestyle.Singleton);
            container.Register<ICommunityResource, CommunityResource>(Lifestyle.Singleton);
            container.Register<ICommentLikesResource, CommentLikesResource>(Lifestyle.Singleton);
            container.Register<IPostsResource, PostsResource>(Lifestyle.Singleton);
            container.Register<IUsersResource, UsersResource>(Lifestyle.Singleton);
            container.Register<IPostLikesResource, PostLikesResource>(Lifestyle.Singleton);
            container.Register<IPostContentsResource, PostContentsResource>(Lifestyle.Singleton);
            container.Register<IMediaResource, MediaResource>(Lifestyle.Singleton);
            container.Register<IAlbumResource, AlbumResource>(Lifestyle.Singleton);
            container.Register<IEducationResource, EducationResource>(Lifestyle.Singleton);
            container.Register<IHobbyResource, HobbyResource>(Lifestyle.Singleton);
            container.Register<IAddressResource, AddressResource>(Lifestyle.Singleton);
            container.Register<ITagsResource, TagsResource>(Lifestyle.Singleton);
            container.Register<IViewCountResource, ViewCountResource>(Lifestyle.Singleton);
            container.Register<IChatMessagesResource, ChatMessagesResource>(Lifestyle.Singleton);

            // SI Helpers and Utilities registry
            container.Register<IImageHelper, ImageHelper>(Lifestyle.Singleton);
            container.Register<IErrorSignaler, ErrorSignaler>(Lifestyle.Singleton);
            container.Register<IHttpClientHelper, HttpClientHelper>(Lifestyle.Singleton);
            container.Register<IConfigurationHelper, ConfigurationHelper>(Lifestyle.Singleton);

            // SI Token Identity registry
            container.Register<IdentityDbContext<BlogUser>, BlogIdentityDbContext>(Lifestyle.Singleton);
            container.Register<IUserStore<BlogUser>, BlogUserStore>(Lifestyle.Singleton);
            container.Register<IBlogDbRepository, BlogDbRepository>(Lifestyle.Singleton);
            container.Register<BlogUserManager, BlogUserManager>(Lifestyle.Singleton);

            // SI Registrations
            container.RegisterMvcControllers(System.Reflection.Assembly.GetExecutingAssembly());
            container.RegisterMvcIntegratedFilterProvider();
            container.RegisterWebApiFilterProvider(GlobalConfiguration.Configuration);

            container.Verify();

            // Register the dependency resolver.
            GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
            GlobalConfiguration.Configuration.EnsureInitialized();
        }
		public static void SetupIoc()
		{
			var container = new Container();
			SetupDependencies(container);
			container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
			container.RegisterMvcIntegratedFilterProvider();
			container.Verify();
			DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
		}
        /// <summary>Initialize the container and register it as MVC Dependency Resolver.</summary>
        public static void InitializeInjector(Container container)
        {
            InitializeContainer(container);

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            container.RegisterMvcIntegratedFilterProvider();

            #if DEBUG
            container.Verify();
            #endif
        }
        public static void SetResolver() {
            var container = new Container();
            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.RegisterMvcIntegratedFilterProvider();

            RegisterDependencies(container);

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
Beispiel #9
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var container = new Container();
            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            var dataModelAssembly = typeof(IUnitOfWork).Assembly;

            var dataModelRegistrations =
                from type in dataModelAssembly.GetExportedTypes()
                where type.Namespace == "DanCanKanBan.DataModel.UnitOfWork"
                where type.GetInterfaces().Any()
                select new { Service = type.GetInterfaces().Single(), Implementation = type };

            foreach (var reg in dataModelRegistrations)
            {
                container.Register(reg.Service, reg.Implementation, Lifestyle.Scoped);
            }

            var serviceAssembly = typeof(IUserService).Assembly;

            var serviceRegistrations =
               from type in serviceAssembly.GetExportedTypes()
               where type.Namespace == "DanCanKanBan.Services.Services"
               where type.GetInterfaces().Any()
               select new { Service = type.GetInterfaces().Single(), Implementation = type };

            foreach (var reg in serviceRegistrations)
            {
                container.Register(reg.Service, reg.Implementation, Lifestyle.Scoped);
            }

            container.Register<IConfigurationSettings, WebConfigurationSettings>(Lifestyle.Scoped);
            container.Register<IUserSession, WebUserSession>(Lifestyle.Scoped);

            // This is an extension method from the integration package.
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            // This is an extension method from the integration package as well.
            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
Beispiel #10
0
        public void Register(Container container)
        {
            container.RegisterSingle<IUserStore<ApplicationUser, Guid>, ApplicationUserStore>();
            container.RegisterSingle<IIdentityMessageService, ApplicationIdentityMessageService>();
            container.RegisterSingle<ApplicationUserManager>();

            container.RegisterPerWebRequest<ApplicationSignInManager>();
            container.RegisterPerWebRequest<IUserContext, UserContext>();
            container.RegisterPerWebRequest<IContextService, ContextService>();

            container.RegisterMvcIntegratedFilterProvider();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
        public static void Initialize()
        {
            _container = new Container();
            _container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            InitializeContainer(_container);
            _container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            _container.RegisterMvcIntegratedFilterProvider();

            var dependencyResolver = new SimpleInjectorDependencyResolver(_container);
            DependencyResolver.SetResolver(dependencyResolver);
            DomainEvent.Container = new DomainEventContainer(dependencyResolver);

            _container.Verify();
        }
 protected void Application_Start()
 {
     // default MVC stuff
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     // Simple Injector set up
     var container = new Container();
     container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();
     // Register your stuff here  
     container.Register<ITestService, TestService>(Lifestyle.Scoped);
     container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
     container.RegisterMvcIntegratedFilterProvider();
     container.Verify();
     DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
 }
Beispiel #13
0
        private void InjectDependencies()
        {
            var container = new Container();

            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            container.Register<IChatService, ChatService>(Lifestyle.Scoped);

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
Beispiel #14
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            var container = new Container();

            new Sci.EventStore.Infrastructure.Injection.Container().Register(container);

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
        public static void RegisterInjections()
        {
            var container = new Container();
            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();
            container.Options.AllowOverridingRegistrations = true;

            // Rejestrujemy nasz DbContext, który simple injector "wstrzyknie" do kontrolera

            // This is an extension method from the integration package.
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.Options.AllowOverridingRegistrations = false;

            // This is an extension method from the integration package as well.
            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
Beispiel #16
0
        public static void Register()
        {
            // Create the container as usual.
            var container = new Container();
            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            // Register your types
            Registrator.RegisterReaders(container);

            // This is an extension method from the integration package.
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            // This is an extension method from the integration package as well.
            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
Beispiel #17
0
        public static void Register()
        {
            // Create the container as usual.
            var container = new Container();
            container.Options.PropertySelectionBehavior = new ImportPropertySelectionBehavior();

            // Subs
            Dragon.Web.DependencyConfig.Register(container);

            // This is an extension method from the integration package.
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            // This is an extension method from the integration package as well.
            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
        private static void ConfigMVC()
        {
            var container = new Container();
            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();
            Common.SimpleInjectorCommon.RegisterItems(container, Lifestyle.Scoped);

            // Register your types, for instance:
            //container.Register<IUserRepository, SqlUserRepository>(Lifestyle.Scoped);

            // This is an extension method from the integration package.
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            // This is an extension method from the integration package as well.
            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
Beispiel #19
0
        /// <summary>
        /// Dependency Injection init.
        /// Alle Componenten registrieren, Integration mit ASP.NET MVC, ASP.NET WebApi.
        /// </summary>
        /// <param name="container"></param>
        private void _InitDependencyInjection(Container container)
        {
            if (container == null) throw new ArgumentNullException("container");

            container.RegisterPackages(new Type[] { 
                typeof(DependencyInjectionConfig),
                typeof(Llprk.Application.DependencyInjectionConfig),
            }.Select(t => Assembly.GetAssembly(t)));

            // Controller für DI registrieren.
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            // Container mit MVC verbinden.
            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
            GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
        }
        public static void Configure()
        {
            var container = new Container();

            container.RegisterPerWebRequest<IDataContext>(() => new CmsContext());

            container.RegisterPerWebRequest<IReadStore, ReadStore>();

            container.RegisterPerWebRequest<IWriteStore, WriteStore>();

            container.Scan(typeof(CommandManager).Assembly);

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
        protected void Application_Start()
        {
            var container = new Container();
            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();
            container.Register<DbContext, ApplicationDbContext>();
            container.Register<IRepository<Image>, Repository<Image>>();
            container.Register<IUserStore<ApplicationUser>>(() => new UserStore<ApplicationUser>(new ApplicationDbContext()));
            container.Register<IAuthenticationManager>(() => HttpContext.Current.GetOwinContext().Authentication);
            container.Register<ApplicationUserManager, ApplicationUserManager>();
            container.Register<ApplicationSignInManager, ApplicationSignInManager>();

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.RegisterMvcIntegratedFilterProvider();
            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
        public static Container Bootstrap(Container container)
        {
            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            Website.Configuration.SimpleInjectorBootstrapper.ScanAssembly(container);
            Common.Configuration.SimpleInjectorBootstrapper.ScanAssembly(container);
            Twitter.Configuration.SimpleInjectorBootstrapper.ScanAssembly(container);

            // This is an extension method from the integration package.
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            // This is an extension method from the integration package as well.
            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));

            return container;
        }
        public static Container Build()
        {
            var container = new Container();
            container.RegisterPerWebRequest<IDbContext>(() => new AppDbContext("AppDb"));
            container.RegisterPerWebRequest<ICurrentUser,FormsAuthenticationCurrentUser>();
            container.RegisterSingle<ICacheProvider,AppCacheProvider>();
            container.Register<ILogger,NLogLogger>();

            container.RegisterManyForOpenGeneric(typeof(IGridModelBuilder<,>), typeof(IGridModelBuilder<,>).Assembly);
            container.RegisterManyForOpenGeneric(typeof(IModelBuilder<>), typeof(IModelBuilder<>).Assembly);
            container.RegisterManyForOpenGeneric(typeof(IModelBuilder<,>), typeof(IModelBuilder<,>).Assembly);
            container.RegisterManyForOpenGeneric(typeof(IModelHandler<>), typeof(IModelHandler<>).Assembly);
            container.RegisterManyForOpenGeneric(typeof(IModelHandler<,>), typeof(IModelHandler<,>).Assembly);
            container.RegisterManyForOpenGeneric(typeof(IFileModelBuilder<>), typeof(IFileModelBuilder<>).Assembly);
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();
            return container;
        }
        public static void Configure()
        {
            var container = new Container();

            container.RegisterPerWebRequest<MyDbContext>();

            container.RegisterPerWebRequest<UserManager>();

            container.RegisterPerWebRequest<RoleManager>();

            container.RegisterPerWebRequest<ClaimedActionsProvider>();

            container.Register<SignInManager>();

            container.RegisterPerWebRequest(() => HttpContext.Current.GetOwinContext().Authentication);

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            container.RegisterMvcIntegratedFilterProvider();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        public static void Initialize(Container container)
        {
            try
            {
                //var container = SimpleDependencyInjector.Instance;
                container.RegisterPackages();

                container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
                container.RegisterWebApiFilterProvider(GlobalConfiguration.Configuration);

                container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
                container.RegisterMvcIntegratedFilterProvider();
                container.Verify();

                MapperInitializer.RegisterMapper(container);
                System.Web.Http.GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
                System.Web.Mvc.DependencyResolver.SetResolver(new SimpleInjector.Integration.Web.Mvc.SimpleInjectorDependencyResolver(container));
            }
            catch (Exception ex)
            {
                ex.ExceptionValueTracker();
            }
        }
        public static void Bootstrap()
        {
            // Did you know the container can diagnose your configuration? Go to: https://bit.ly/YE8OJj.
            var container = new Container();

            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            BusinessLayerBootstrapper.Bootstrap(container);

            RegisterWebApiSpecificDependencies(container);

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            container.RegisterMvcIntegratedFilterProvider();

            container.Verify();

            GlobalConfiguration.Configuration.DependencyResolver =
                new SimpleInjectorWebApiDependencyResolver(container);

            System.Web.Mvc.DependencyResolver.SetResolver(
                new SimpleInjector.Integration.Web.Mvc.SimpleInjectorDependencyResolver(container));
        }
 private static void RegisterMvc(Container container)
 {
     container.RegisterMvcIntegratedFilterProvider();
     container.Register(typeof(HttpContextBase), () => new HttpContextWrapper(HttpContext.Current));
 }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            #region SimpleInjector

            var container = new Container();
            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();
            container.Register<IUserRepository, UserRepository>(Lifestyle.Scoped);
            container.Register<IWidgetRepository, WidgetRepository>(Lifestyle.Scoped);
            container.Register<IUserCase, UserCase>(Lifestyle.Scoped);
            container.Register<IWidgetCase, WidgetCase>(Lifestyle.Scoped);
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.RegisterMvcIntegratedFilterProvider();
            container.Verify();
            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));

            #endregion
        }
        /// <summary>Initialize the container and register it as MVC3 Dependency Resolver.</summary>
        public static void Initialize()
        {
            var container = new Container();
            container.Options.PropertySelectionBehavior = new ImportPropertySelectionBehavior();

            Register(container);

            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.RegisterMvcIntegratedFilterProvider();

            try
            {
                container.Verify();
            }
            catch (Exception e)
            {
                Trace.TraceError("Failed to initialize IoC container: {0}", e);
                throw;
            }

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));

            try
            {
                new TraceListenersInitializer(container.GetInstance<IPortalFrontendSettings>(), container.GetInstance<IEmailSenderService>()).Initialize();
            }
            catch (Exception e)
            {
                Trace.TraceError("Failed to initialize trace listeners: {0}", e);
                throw;
            }
        }
Beispiel #30
0
 public void Register(Container container)
 {
     container.RegisterMvcControllers(typeof(Web.Controllers.HomeController).Assembly);
     container.RegisterMvcIntegratedFilterProvider();
 }