示例#1
0
        /// <summary>
        /// Adds scope as a child scope.
        /// </summary>
        /// <param name="scope">Add the specified scope.</param>
        /// <returns>
        /// true if child scope was successfully added, false otherwise.
        /// </returns>
        public bool AddChildScope(IBasicScope scope)
        {
            if (HasChildScope(scope.Type, scope.Name))
            {
#if !SILVERLIGHT
                log.Warn(string.Format("Child scope {0} already exists", scope.Name));
#endif
                return(false);
            }

            if (HasHandler && !Handler.AddChildScope(scope))
            {
#if !SILVERLIGHT
                if (log != null && log.IsDebugEnabled)
                {
                    log.Debug("Failed to add child scope: " + scope + " to " + this);
                }
#endif
                return(false);
            }
            if (scope is IScope)
            {
                // Start the scope
                if (HasHandler && !Handler.Start((IScope)scope))
                {
#if !SILVERLIGHT
                    if (log != null && log.IsDebugEnabled)
                    {
                        log.Debug("Failed to start child scope: " + scope + " in " + this);
                    }
#endif
                    return(false);
                }
            }
#if !SILVERLIGHT
            if (scope is Scope)
            {
                //Chain service containers
                (scope as Scope).ServiceContainer.Container = ServiceContainer;
            }
            if (log != null && log.IsDebugEnabled)
            {
                log.Debug("Add child scope: " + scope + " to " + this);
            }
#endif
            _children[scope.Type + Separator + scope.Name] = scope;
            _subscopeStats.Increment();
            return(true);
        }
示例#2
0
        public bool AddChildScope(IBasicScope scope)
        {
            if (HasHandler && !Handler.AddChildScope(scope))
            {
                return(false);
            }

            if (scope is IScope)
            {
                // Start the scope
                if (HasHandler && !Handler.Start((IScope)scope))
                {
                    return(false);
                }
            }
            _children[scope.Type + Separator + scope.Name] = scope;
            return(true);
        }