/// <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;
     UnityConfig.GetConfiguredContainer().Resolve<IReflector>().Reflect();
 }
Example #2
0
            /// <summary>Integrates Unity when the application starts.</summary>
            public static void Start()
            {
                var container = UnityConfig.GetConfiguredContainer();

                // Use UnityHierarchicalDependencyResolver if you want to use a new child container for each IHttpController resolution.
                // var resolver = new WebApi.UnityHierarchicalDependencyResolver(container);
                var resolver = new UnityDependencyResolver(container);
                GlobalConfiguration.Configuration.DependencyResolver = resolver;
            }
Example #3
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 Microsoft.Practices.Unity.WebApi.UnityDependencyResolver(UnityConfig.GetConfiguredContainer());

            GlobalConfiguration.Configuration.DependencyResolver = resolver;

            DynamicModuleUtility.RegisterModule(typeof(UnityPerRequestHttpModule));
        }
        /// <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 container = UnityConfig.GetConfiguredContainer();
            var resolver = new UnityDependencyResolver(container);

            //Set resolver for MVC
            DependencyResolver.SetResolver(new Unity.Mvc5.UnityDependencyResolver(container));

            //Set resolver for Web API
            GlobalConfiguration.Configuration.DependencyResolver = resolver;
        }
 /// <summary>Integrates Unity when the application starts.</summary>
 public static void Start() {
     try {
         // 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;
         UnityConfig.GetConfiguredContainer().Resolve<IReflector>().Reflect();
     }
     catch (Exception e) {
         Logger.Error($"Error on UnityWebApiActivator:Start : {e.Message}");
         throw;
     }
 }
Example #6
0
        public void Register(HttpConfiguration config)
        {
            var resolver = new UnityDependencyResolver(_container);
            config.DependencyResolver = resolver;

            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
		/// <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;

			// added for WebApi.OutputCache cache output provider
			GlobalConfiguration.Configuration.CacheOutputConfiguration()
				.RegisterCacheOutputProvider(() => new MemoryCacheDefault());
			//GlobalConfiguration.Configuration.CacheOutputConfiguration()
			//	.RegisterCacheOutputProvider(() => new RedisApiOutputCache());
			GlobalConfiguration.Configuration.CacheOutputConfiguration()
				.RegisterDefaultCacheKeyGeneratorProvider(() => new DefaultCacheKeyGenerator());
		}
        public static void Start()
        {
            var resolver = new UnityDependencyResolver(UnityConfig.GetConfiguredContainer());

            GlobalConfiguration.Configuration.DependencyResolver = resolver;
        }