Esempio n. 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterControllers(typeof(MvcApplication).Assembly).InstancePerRequest().PropertiesAutowired();
            builder.RegisterApiControllers(typeof(MvcApplication).Assembly).InstancePerRequest();

            IConfigurationBuilder config = new ConfigurationBuilder();

            config.AddJsonFile("autofac.json");

            ConfigurationModule module = new ConfigurationModule(config.Build());

            builder.RegisterModule(module);

            IContainer container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);

            IExtensibilityManager extensibilityManager = container.Resolve <IExtensibilityManager>();

            extensibilityManager.GetModuleEvents(); // stores them in state
        }
Esempio n. 2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //IExtensibilityManager extensibilityManager = new ExtensibilityManager();



            ContainerBuilder    builder            = new ContainerBuilder();
            IDependencyResolver dependencyResolver = DependencyResolver.Current;

            if (dependencyResolver.GetType() != typeof(AutofacDependencyResolver))
            {
                //builder.RegisterType<HomeController>();

                //registracija svih mvc controllera
                builder.RegisterControllers(typeof(MvcApplication).Assembly)
                .InstancePerRequest()
                .PropertiesAutowired();

                builder.RegisterApiControllers(typeof(MvcApplication).Assembly).InstancePerRequest();


                //builder.RegisterModule<RepositoryRegistrationModule>();

                //builder.RegisterType<Tester>().As<ITester>().SingleInstance();
                //builder.RegisterType<ExtensibilityManager>().As<IExtensibilityManager>().SingleInstance();



                //repozitoriji jedan po jedan
                //builder.RegisterType<BlogPostRepository>().As<IBlogPostRepository>()
                //       .WithParameter(new TypedParameter(typeof(string), "easyBog"));
                //.WithParameter(new NamedParameter("connectionStringName", "easyBog"));


                IConfigurationBuilder config = new ConfigurationBuilder();
                config.AddJsonFile("autofac.json");

                ConfigurationModule configurationModule = new ConfigurationModule(config.Build());

                builder.RegisterModule(configurationModule);
                IContainer container = builder.Build();
                //resolvanje dependencija
                DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
                GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);

                IExtensibilityManager extensibilityManager = container.Resolve <IExtensibilityManager>();

                //if (Application["ModuleEvents"] == null)
                extensibilityManager.GetModuleEvents();
            }
        }
Esempio n. 3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ContainerBuilder builder = new ContainerBuilder();

            //builder.RegisterType<HomeController>();

            builder.RegisterControllers(typeof(MvcApplication).Assembly).InstancePerRequest();
            builder.RegisterApiControllers(typeof(MvcApplication).Assembly).InstancePerRequest();

            //builder.RegisterType<Tester>().As<ITester>().SingleInstance();
            //builder.RegisterType<ExtensibilityManager>().As<IExtensibilityManager>().SingleInstance();
            //builder.RegisterType<BlogPostRepository>().As<IBlogPostRepository>().WithParameter(new TypedParameter(typeof(string), "easyBlog"));
            //builder.RegisterModule<RepositoryRegistrationModule>();

            IConfigurationBuilder config = new ConfigurationBuilder();

            config.AddJsonFile("autofac.json");

            ConfigurationModule module = new ConfigurationModule(config.Build());

            builder.RegisterModule(module);

            IContainer container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);

            IExtensibilityManager extensibilityManager = container.Resolve <IExtensibilityManager>();

            extensibilityManager.GetModuleEvents(); // stores them in state
        }