Esempio n. 1
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            UnityConfigRegistrationsGenerated.RegisterTypes(container);
            UnityConfigServiceRegistrationsGenerated.RegisterTypes(container);
            UnityConfigRegistrations.RegisterSingleton(container);
            UnityConfigRegistrations.RegisterTypes(container);
            UnityConfigRegistrations.RegisterTransient(container);

            var serviceLocator = new UnityServiceLocator(container);

            ServiceLocator.SetLocatorProvider(() =>
            {
                return(serviceLocator);
            });
        }
Esempio n. 2
0
        /// <summary></summary>
        public static void RegisterTypes(IUnityContainer container)
        {
            //var myAssemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.FullName.StartsWith("SelfHostWebApiOwin")).ToArray();

            container.RegisterType(typeof(Startup));
            UnityConfigRegistrationsGenerated.RegisterTypesOwin(container);
            UnityConfigServiceRegistrationsGenerated.RegisterTypesOwin(container);
            UnityConfigRegistrations.RegisterTypesOwin(container);
            UnityConfigRegistrations.RegisterSingleton(container);

            /*
             * container.RegisterTypes(
             *  UnityHelpers.GetTypesWithCustomAttribute<UnityIoCContainerControlledAttribute>(myAssemblies),
             *  WithMappings.FromMatchingInterface,
             *  WithName.Default,
             *  WithLifetime.ContainerControlled,
             *  null
             *  ).RegisterTypes(
             *           UnityHelpers.GetTypesWithCustomAttribute<UnityIoCTransientLifetimeAttribute>(myAssemblies),
             *           WithMappings.FromMatchingInterface,
             *           WithName.Default,
             *           WithLifetime.Transient);
             */
        }