Beispiel #1
0
        private static IUnityContainer BuildUnityContainer()
        {
            IUnityContainer container = new UnityContainer();

            InjectFactory.SetContainer(container.CreateChildContainer());

            RegisterTypes(container);

            return(container);
        }
Beispiel #2
0
        public static void Build(IUnityContainer container)
        {
            InjectFactory.SetContainer(container);

            //Assembly[] assemblies = BuildManager.GetReferencedAssemblies().OfType<Assembly>().ToArray();

            //container.RegisterTypes(
            //    AllClasses.FromLoadedAssemblies()
            //        .Where(
            //            a =>
            //                a.FullName.StartsWith("AppUsage")
            //        //a.FullName.StartsWith("AppUsage") &&
            //        //(a.FullName.EndsWith("Business") || a.FullName.EndsWith("Application"))
            //        ),
            //        WithMappings.FromMatchingInterface,
            //        WithName.Default,
            //        WithLifetime.Hierarchical);

            buildContext(container, new HierarchicalLifetimeManager());
            buildInfrastructure(container, new HierarchicalLifetimeManager());
            buildBusinessServices(container, new HierarchicalLifetimeManager());
            buildApplicationServices(container, new HierarchicalLifetimeManager());
        }