Exemplo n.º 1
0
        protected virtual void RegisterDependencies(IConfigurationSectionHandler config)
        {
            var builder   = new ContainerBuilder();
            var container = builder.Build();

            this._containerManager = new ContainerManager(container);

            //dependencies
            var typeFinder = new WebAppTypeFinder();

            builder = new ContainerBuilder();
            builder.RegisterInstance(typeFinder).As <ITypeFinder>().SingleInstance();
            builder.Update(container);



            //foreach (var dependencyRegistrar
            //               in new Type[]{
            //                   typeof(DependencyRegistrar)
            //                  ,typeof(Repos.DomainModel.Interface.DependencyRegistrar)
            //                  ,typeof(ReposDomain.Handlers.DependencyRegistrar)
            //               })

            //{
            //    var dep = (IDependencyRegistrar)Activator.CreateInstance(dependencyRegistrar);
            //    builder = new ContainerBuilder();
            //    dep.Register(builder, container, null, config, new DefaultConfOptions());
            //    builder.Update(container);
            //}

            ReqisterDependencies.DependencyRegister(container, config, new DefaultConfOptions());
        }
Exemplo n.º 2
0
        protected virtual void RegisterDependencies(ReposConfig config, IConfigOptions options)
        {
            var builder   = new ContainerBuilder();
            var container = builder.Build();

            this._containerManager = new ContainerManager(container);

            //we create new instance of ContainerBuilder
            //because Build() or Update() method can only be called once on a ContainerBuilder.

            //dependencies
            var typeFinder = new WebAppTypeFinder();

            builder = new ContainerBuilder();

            if (config != null)
            {
                builder.RegisterInstance(config).As <ReposConfig>().SingleInstance();
            }

            builder.RegisterInstance(this).As <IEngine>().SingleInstance();
            builder.RegisterInstance(typeFinder).As <ITypeFinder>().SingleInstance();
            builder.Update(container);

            if (config != null && !config.DLLValidation)
            {
                options.Remove(enumConfigOpts.NoDLLValidation);
            }

            ReqisterDependencies.DependencyRegister(container, config, options);
        }
Exemplo n.º 3
0
        protected virtual void RegisterDependencies(ReposConfig config, IConfigOptions options)
        {
            var builder   = new ContainerBuilder();
            var container = builder.Build();

            this._containerManager = new ContainerManager(container);

            //we create new instance of ContainerBuilder
            //because Build() or Update() method can only be called once on a ContainerBuilder.

            //dependencies
            var typeFinder = new WebAppTypeFinder();

            builder = new ContainerBuilder();
            builder.RegisterInstance(config).As <ReposConfig>().SingleInstance();
            builder.RegisterInstance(this).As <IEngine>().SingleInstance();
            builder.RegisterInstance(typeFinder).As <ITypeFinder>().SingleInstance();
            builder.Update(container);

            if (!config.DLLValidation)
            {
                options.Remove(enumConfigOpts.NoDLLValidation);
            }

            ReqisterDependencies.DependencyRegister(container, config, options);

            builder = new ContainerBuilder();

            var assm = typeFinder.App.GetAssemblies().ToArray();

            //set dependency resolver
            if (config.ResolverType == ResolverType)
            {
                builder.RegisterControllers(assm);
                builder.Update(container);
                // 10/27 somehow this broke
                // and had to use the full declaration
                System.Web.Mvc.DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            }
            else if (config.ResolverType == "WebWcf")
            {
                AutofacHostFactory.Container = container;
            }
            else
            {
                builder.RegisterApiControllers(assm);
                builder.Update(container);
                var webApiResolver = new AutofacWebApiDependencyResolver(container);
                GlobalConfiguration.Configuration.DependencyResolver = webApiResolver;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Register dependencies
        /// </summary>
        /// <param name="config">Config</param>

#if DI_UNITY
        protected virtual void RegisterDependencies(ReposConfig config, IConfigOptions options)
        {
            var container = new UnityContainer();

            this._containerManager = new ContainerManager(container);

            //we create new instance of ContainerBuilder
            //because Build() or Update() method can only be called once on a ContainerBuilder.

            //dependencies
            var typeFinder = new WebAppTypeFinder();

            container.RegisterInstance <IConfigurationSectionHandler>(config, new SingletonLifetimeManager());
            container.RegisterInstance <IEngine>(this, new SingletonLifetimeManager());
            container.RegisterInstance <ITypeFinder>(typeFinder, new SingletonLifetimeManager());


            if (!config.DLLValidation)
            {
                options.Remove(enumConfigOpts.NoDLLValidation);
            }

            ReqisterDependencies.DependencyRegister(container, config, options);


            //set dependency resolver
            if (config.ResolverType == ResolverType)
            {
                var resolver = new UnityDependencyResolver(container);
                System.Web.Mvc.DependencyResolver.SetResolver(resolver);
            }
            else
            {
                var resolver = new UnityDependencyResolver(container);
                GlobalConfiguration.Configuration.DependencyResolver = resolver;
            }
        }