Пример #1
0
        /// <summary>Integrates Unity when the application starts.</summary>
        public static void Start()
        {
            // Use UnityHierarchicalDependencyResolver if you want to use a new child container for each IHttpController resolution.
            // var resolver = new UnityHierarchicalDependencyResolver(UnityConfig.GetConfiguredContainer());
            var resolver = new UnityDependencyResolver(UnityConfig.GetConfiguredContainer());

            GlobalConfiguration.Configuration.DependencyResolver = resolver;
        }
Пример #2
0
        public static void RegisterComponents()
        {
            Container = new UnityContainer();

            // register all your components with the container here
            // it is NOT necessary to register your controllers

            // e.g. container.RegisterType<ITestService, TestService>();
            Container.RegisterInstance(CreateExampleDatabase());

            unityMvc5Resolver = new Unity.Mvc5.UnityDependencyResolver(Container);
            DependencyResolver.SetResolver(unityMvc5Resolver);
            unityWebApiResolver = new UnityDependencyResolver(Container);
            GlobalConfiguration.Configuration.DependencyResolver = unityWebApiResolver;
        }
        public static void RegisterComponents()
        {
            var container = new UnityContainer();

            container.RegisterType<DbContext, Context>(new HierarchicalLifetimeManager());
            container.RegisterType<IUnitOfWork, UnitOfWork>(new HierarchicalLifetimeManager());
            container.RegisterType<IAudioFileService, AudioFileService>();
            container.RegisterType<IExhibitService, ExhibitService>();
            container.RegisterType<ICustomerService, CustomerService>();
            container.RegisterType<IHandsetService, HandsetService>();
            container.RegisterType<ILanguageService, LanguageService>();
            container.RegisterType<IKnowledgeLevelService, KnowledgeLevelService>();

            var resolver = new UnityDependencyResolver(container);

            GlobalConfiguration.Configuration.DependencyResolver = resolver;
        }