Application Context for ASP.NET MVC Applications
Наследование: Spring.Context.Support.AbstractXmlApplicationContext
        /// <summary>
        /// 
        /// </summary>
        /// <returns>The initialized <see cref="IDependencyScope"/> instance.</returns>
        /// <exception cref="NotImplementedException"></exception>
        public virtual IDependencyScope BeginScope()
        {
            if (HasApplicationContext && (HasChildApplicationContextConfigurationLocations || HasChildApplicationContextConfigurationResources))
            {
                string[] configurationLocations = null;
                if (HasChildApplicationContextConfigurationLocations)
                {
                    configurationLocations = ChildApplicationContextConfigurationLocations.ToArray();
                }

                IResource[] configurationResources = null;
                if (HasChildApplicationContextConfigurationResources)
                {
                    configurationResources = ChildApplicationContextConfigurationResources.ToArray();
                }

                var childContextName = string.Format("child_of_{0}", ApplicationContext.Name);
                var args = new MvcApplicationContextArgs(childContextName, ApplicationContext, configurationLocations, configurationResources, false);

                var childContext = new MvcApplicationContext(args);
                var newResolver = new SpringWebApiDependencyResolver(childContext) { ApplicationContextName = childContextName };

                RegisterContextIfNeeded(childContext);

                return newResolver;
            }
            else
            {
                return this;
            }
        }
        public void _TestSetup()
        {
            using (new VirtualEnvironmentMock("/somedir/some.file", null, null, "/", true))
            {
                ContextRegistry.Clear();
                _context = new MvcApplicationContext("file://objects.xml");
                _mvcNamedContext = new MvcApplicationContext("named", false, "file://namedContextObjects.xml");

                ContextRegistry.RegisterContext(_context);
                ContextRegistry.RegisterContext(_mvcNamedContext);

                _factory = new SpringControllerFactory();

                //due to ridiculous internal methods in DefaultControllerFactory, have to set the ControllerTypeCache using this extension method
                // see http://stackoverflow.com/questions/727181/asp-net-mvc-system-web-compilation-compilationlock for more info
                _factory.InitializeWithControllerTypes(new[]
                                                           {
                                                               typeof (FirstContainerRegisteredController),
                                                               typeof (SecondContainerRegisteredController),
                                                               typeof (NotInContainerController),
                                                               typeof (NamedContextController),
                                                           });

                SpringControllerFactory.ApplicationContextName = string.Empty;
            }
        }
        public void _TestSetup()
        {
            ContextRegistry.Clear();
            _context = new MvcApplicationContext("file://objectsMvc.xml");
            _mvcNamedContext = new MvcApplicationContext("named", false, "file://namedContextObjectsMvc.xml");

            ContextRegistry.RegisterContext(_context);
            ContextRegistry.RegisterContext(_mvcNamedContext);

            _resolver = new SpringMvcDependencyResolver(_context);

            _resolver.ApplicationContextName = string.Empty;
        }
        public void CanRevertToTypeMatchIfIdMatchUnsuccessful()
        {
            using (new VirtualEnvironmentMock("/somedir/some.file", null, null, "/", true))
            {
                MvcApplicationContext context = new MvcApplicationContext("file://objectsMatchByType.xml");

                ContextRegistry.Clear();
                ContextRegistry.RegisterContext(context);
            }
            IController controller = _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "FirstContainerRegistered");

            Assert.AreEqual("Should_Be_Matched_By_Type", ((FirstContainerRegisteredController)controller).TestValue);
        }