示例#1
0
        /// <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);
            }
        }
示例#2
0
        /// <summary>
        /// Adds the child configuration location.
        /// </summary>
        /// <param name="location">The location.</param>
        public virtual void AddChildApplicationContextConfigurationLocation(string location)
        {
            if (null == ChildApplicationContextConfigurationLocations)
            {
                ChildApplicationContextConfigurationLocations = new List <string>();
            }

            ChildApplicationContextConfigurationLocations.Add(location);
        }