public static void PreApplicationStart()
        {
            var filterAttributeFilterProvider = FilterProviders.Providers.OfType<FilterAttributeFilterProvider>().First();
            var unityFilterAttributeFilterProvider = new UnityFilterAttributeFilterProvider(Injector.Default.Container);
            var unityDependencyResolver = new UnityDependencyResolver(Injector.Default.Container);

            FilterProviders.Providers.Remove(filterAttributeFilterProvider);
            FilterProviders.Providers.Add(unityFilterAttributeFilterProvider);
            DependencyResolver.SetResolver(unityDependencyResolver);
        }
Esempio n. 2
0
        /// <summary>Integrates Unity when the application starts.</summary>
        public static void Start() 
        {
            var container = UnityConfig.GetConfiguredContainer();

            FilterProviders.Providers.Remove(FilterProviders.Providers.OfType<FilterAttributeFilterProvider>().First());
            FilterProviders.Providers.Add(new UnityFilterAttributeFilterProvider(container));

            var dependencyResolver = new UnityDependencyResolver(container);
            var locatorProvider = new UnityDependencyResolverServiceLocatorProvider(dependencyResolver);
            ServiceLocator.SetLocatorProvider(() => locatorProvider);
            DependencyResolver.SetResolver(dependencyResolver);

            GlobalConfiguration.Configuration.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(container);

            // TODO: Uncomment if you want to use PerRequestLifetimeManager
            // Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(typeof(UnityPerRequestHttpModule));
        }
        /// <summary>
        /// Integrates Unity when the application starts.
        /// </summary>
        public static void Start() 
        {
            var container = UnityConfig.GetConfiguredContainer();

            FilterProviders.Providers.Remove(FilterProviders.Providers.OfType<FilterAttributeFilterProvider>().First());
            FilterProviders.Providers.Add(new UnityFilterAttributeFilterProvider(container));

			var dependencyResolver = new UnityDependencyResolver(container);
			var locatorProvider = new UnityDependencyResolverServiceLocatorProvider(dependencyResolver);
			ServiceLocator.SetLocatorProvider(() => locatorProvider);
			DependencyResolver.SetResolver(dependencyResolver);

			GlobalConfiguration.Configuration.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(container);

			if (!AzureCommonHelper.IsAzureEnvironment() && AppConfigConfiguration.Instance.Setup.IsCompleted)
			{
				SchedulerHost.CreateScheduler();
			}
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UnityDependencyResolverServiceLocatorProvider"/> class.
 /// </summary>
 /// <param name="unityDependencyResolver">The unity dependency resolver.</param>
 public UnityDependencyResolverServiceLocatorProvider(UnityDependencyResolver unityDependencyResolver)
 {
     _unityDependencyResolver = unityDependencyResolver;
 }