/// <summary> Refresh named objects from the interceptor chain.
        /// We need to do this every time a new prototype instance is returned,
        /// to return distinct instances of prototype interfaces and pointcuts.
        /// </summary>
        private IList FreshIntroductionChain()
        {
            IIntroductionAdvisor[] introductions = Introductions;
            ArrayList freshIntroductions         = new ArrayList();

            foreach (IIntroductionAdvisor introduction in introductions)
            {
                if (introduction is PrototypePlaceholder)
                {
                    PrototypePlaceholder pa = (PrototypePlaceholder)introduction;
                    #region Instrumentation
                    if (logger.IsDebugEnabled)
                    {
                        logger.Debug(string.Format("Refreshing introduction '{0}'", pa.ObjectName));
                    }
                    #endregion
                    AssertUtils.ArgumentNotNull(this.objectFactory, "ObjectFactory");

                    object   introductionObject = this.objectFactory.GetObject(pa.ObjectName);
                    IAdvisor freshIntroduction  = NamedObjectToIntroduction(introductionObject);
                    freshIntroductions.Add(freshIntroduction);
                }
                else
                {
                    freshIntroductions.Add(introduction);
                }
            }
            return(freshIntroductions);
        }
        /// <summary> Refresh named objects from the interceptor chain.
        /// We need to do this every time a new prototype instance is returned,
        /// to return distinct instances of prototype interfaces and pointcuts.
        /// </summary>
        private IList FreshAdvisorChain()
        {
            IAdvisor[] advisors      = Advisors;
            ArrayList  freshAdvisors = new ArrayList();

            foreach (IAdvisor advisor in advisors)
            {
                if (advisor is PrototypePlaceholder)
                {
                    PrototypePlaceholder pa = (PrototypePlaceholder)advisor;
                    #region Instrumentation
                    if (logger.IsDebugEnabled)
                    {
                        logger.Debug(string.Format("Refreshing advisor '{0}'", pa.ObjectName));
                    }
                    #endregion
                    AssertUtils.ArgumentNotNull(this.objectFactory, "ObjectFactory");

                    object   advisorObject = this.objectFactory.GetObject(pa.ObjectName);
                    IAdvisor freshAdvisor  = NamedObjectToAdvisor(advisorObject);
                    freshAdvisors.Add(freshAdvisor);
                }
                else
                {
                    freshAdvisors.Add(advisor);
                }
            }
            return(freshAdvisors);
        }
        /// <summary> Refresh named objects from the interceptor chain.
        /// We need to do this every time a new prototype instance is returned,
        /// to return distinct instances of prototype interfaces and pointcuts.
        /// </summary>
        private IList <IIntroductionAdvisor> FreshIntroductionChain()
        {
            IList <IIntroductionAdvisor> introductions      = Introductions;
            List <IIntroductionAdvisor>  freshIntroductions = new List <IIntroductionAdvisor>();

            foreach (IIntroductionAdvisor introduction in introductions)
            {
                if (introduction is PrototypePlaceholder)
                {
                    PrototypePlaceholder pa = (PrototypePlaceholder)introduction;
                    if (logger.IsDebugEnabled)
                    {
                        logger.Debug(string.Format("Refreshing introduction '{0}'", pa.ObjectName));
                    }

                    AssertUtils.ArgumentNotNull(objectFactory, "ObjectFactory");

                    object introductionObject = objectFactory.GetObject(pa.ObjectName);
                    IIntroductionAdvisor freshIntroduction = NamedObjectToIntroduction(introductionObject);
                    freshIntroductions.Add(freshIntroduction);
                }
                else
                {
                    freshIntroductions.Add(introduction);
                }
            }
            return(freshIntroductions);
        }
        /// <summary> Refresh named objects from the interceptor chain.
        /// We need to do this every time a new prototype instance is returned,
        /// to return distinct instances of prototype interfaces and pointcuts.
        /// </summary>
        private IList <IAdvisor> FreshAdvisorChain()
        {
            IList <IAdvisor> advisors      = Advisors;
            List <IAdvisor>  freshAdvisors = new List <IAdvisor>();

            foreach (IAdvisor advisor in advisors)
            {
                if (advisor is PrototypePlaceholder)
                {
                    PrototypePlaceholder pa = (PrototypePlaceholder)advisor;
                    if (logger.IsDebugEnabled)
                    {
                        logger.Debug(string.Format("Refreshing advisor '{0}'", pa.ObjectName));
                    }

                    AssertUtils.ArgumentNotNull(objectFactory, "ObjectFactory");

                    object   advisorObject = objectFactory.GetObject(pa.ObjectName);
                    IAdvisor freshAdvisor  = NamedObjectToAdvisor(advisorObject);
                    freshAdvisors.Add(freshAdvisor);
                }
                else
                {
                    freshAdvisors.Add(advisor);
                }
            }
            return(freshAdvisors);
        }
        /// <summary>
        /// Configures introductions for this proxy.
        /// </summary>
        private void InitializeIntroductionChain()
        {
            if (ObjectUtils.IsEmpty(this.introductionNames))
            {
                return;
            }

            // Materialize introductions from object names...
            foreach (string name in this.introductionNames)
            {
                if (name == null)
                {
                    throw new AopConfigException("Found null interceptor name value in the InterceptorNames list; check your configuration.");
                }

                #region Instrumentation
                if (logger.IsDebugEnabled)
                {
                    logger.Debug("Adding introduction '" + name + "'");
                }
                #endregion

                if (name.EndsWith(GlobalInterceptorSuffix))
                {
                    if (!(this.objectFactory is IListableObjectFactory))
                    {
                        throw new AopConfigException("Can only use global introductions with a ListableObjectFactory");
                    }
                    AddGlobalIntroduction((IListableObjectFactory)this.objectFactory, name.Substring(0, (name.Length - GlobalInterceptorSuffix.Length)));
                }
                else
                {
                    // add a named introduction
                    object introduction;
                    if (this.IsSingleton || this.objectFactory.IsSingleton(name))
                    {
                        introduction = this.objectFactory.GetObject(name);
                        AssertUtils.ArgumentNotNull(introduction, "introduction", "object factory returned a null object");
                    }
                    else
                    {
                        introduction = new PrototypePlaceholder(name);
                    }
                    AddIntroductionOnChainCreation(introduction, name);
                }
            }
        }
        /// <summary>
        /// Configures introductions for this proxy.
        /// </summary>
        private void InitializeIntroductionChain()
        {
            if (ObjectUtils.IsEmpty(this.introductionNames))
            {
                return;
            }

            // Materialize introductions from object names...
            foreach (string name in this.introductionNames)
            {
                if (name == null)
                {
                    throw new AopConfigException("Found null interceptor name value in the InterceptorNames list; check your configuration.");
                }

                #region Instrumentation
                if (logger.IsDebugEnabled)
                {
                    logger.Debug("Adding introduction '" + name + "'");
                }
                #endregion

                if (name.EndsWith(GlobalInterceptorSuffix))
                {
                    if (!(this.objectFactory is IListableObjectFactory))
                    {
                        throw new AopConfigException("Can only use global introductions with a ListableObjectFactory");
                    }
                    AddGlobalIntroduction((IListableObjectFactory)this.objectFactory, name.Substring(0, (name.Length - GlobalInterceptorSuffix.Length)));
                }
                else
                {
                    // add a named introduction
                    object introduction;
                    if (this.IsSingleton || this.objectFactory.IsSingleton(name))
                    {
                        introduction = this.objectFactory.GetObject(name);
                        AssertUtils.ArgumentNotNull(introduction, "introduction", "object factory returned a null object");
                    }
                    else
                    {
                        introduction = new PrototypePlaceholder(name);
                    }
                    AddIntroductionOnChainCreation(introduction, name);
                }
            }
        }
        /// <summary>Create the advisor (interceptor) chain.</summary>
        /// <remarks>
        /// The advisors that are sourced from an ObjectFactory will be refreshed each time
        /// a new prototype instance is added. Interceptors added programmatically through 
        /// the factory API are unaffected by such changes.
        /// </remarks>
        private void InitializeAdvisorChain()
        {
            if (ObjectUtils.IsEmpty(this.interceptorNames))
            {
                return;
            }

            CheckInterceptorNames();

            // Globals can't be last unless we specified a targetSource using the property...
            if (this.interceptorNames[this.interceptorNames.Length - 1] != null
                && this.interceptorNames[this.interceptorNames.Length - 1].EndsWith(GlobalInterceptorSuffix)
                && this.targetName == null
                && this.TargetSource == EmptyTargetSource.Empty)
            {
                throw new AopConfigException("Target required after globals");
            }

            // materialize interceptor chain from object names...
            foreach (string name in this.interceptorNames)
            {
                if (name == null)
                {
                    throw new AopConfigException("Found null interceptor name value in the InterceptorNames list; check your configuration.");
                }

                if (name.EndsWith(GlobalInterceptorSuffix))
                {
                    IListableObjectFactory lof = this.objectFactory as IListableObjectFactory;
                    if (lof == null)
                    {
                        throw new AopConfigException("Can only use global advisors or interceptors in conjunction with an IListableObjectFactory.");
                    }

                    #region Instrumentation
                    if (logger.IsDebugEnabled)
                    {
                        logger.Debug("Adding global advisor '" + name + "'");
                    }
                    #endregion

                    AddGlobalAdvisor(lof, name.Substring(0, (name.Length - GlobalInterceptorSuffix.Length)));
                }
                else
                {
                    #region Instrumentation
                    if (logger.IsDebugEnabled)
                    {
                        logger.Debug("resolving advisor name " + "'" + name + "'");
                    }
                    #endregion

                    // If we get here, we need to add a named interceptor.
                    // We must check if it's a singleton or prototype.
                    object advice;
                    if (this.IsSingleton || this.objectFactory.IsSingleton(name))
                    {
                        advice = this.objectFactory.GetObject(name);
                        AssertUtils.ArgumentNotNull(advice, "advice", "object factory returned a null object");
                    }
                    else
                    {
                        advice = new PrototypePlaceholder(name);
                    }
                    AddAdvisorOnChainCreation(advice, name);
                }
            }
        }
        /// <summary>Create the advisor (interceptor) chain.</summary>
        /// <remarks>
        /// The advisors that are sourced from an ObjectFactory will be refreshed each time
        /// a new prototype instance is added. Interceptors added programmatically through
        /// the factory API are unaffected by such changes.
        /// </remarks>
        private void InitializeAdvisorChain()
        {
            if (ObjectUtils.IsEmpty(this.interceptorNames))
            {
                return;
            }

            CheckInterceptorNames();

            // Globals can't be last unless we specified a targetSource using the property...
            if (this.interceptorNames[this.interceptorNames.Length - 1] != null &&
                this.interceptorNames[this.interceptorNames.Length - 1].EndsWith(GlobalInterceptorSuffix) &&
                this.targetName == null &&
                this.TargetSource == EmptyTargetSource.Empty)
            {
                throw new AopConfigException("Target required after globals");
            }

            // materialize interceptor chain from object names...
            foreach (string name in this.interceptorNames)
            {
                if (name == null)
                {
                    throw new AopConfigException("Found null interceptor name value in the InterceptorNames list; check your configuration.");
                }

                if (name.EndsWith(GlobalInterceptorSuffix))
                {
                    IListableObjectFactory lof = this.objectFactory as IListableObjectFactory;
                    if (lof == null)
                    {
                        throw new AopConfigException("Can only use global advisors or interceptors in conjunction with an IListableObjectFactory.");
                    }

                    #region Instrumentation
                    if (logger.IsDebugEnabled)
                    {
                        logger.Debug("Adding global advisor '" + name + "'");
                    }
                    #endregion

                    AddGlobalAdvisor(lof, name.Substring(0, (name.Length - GlobalInterceptorSuffix.Length)));
                }
                else
                {
                    #region Instrumentation
                    if (logger.IsDebugEnabled)
                    {
                        logger.Debug("resolving advisor name " + "'" + name + "'");
                    }
                    #endregion

                    // If we get here, we need to add a named interceptor.
                    // We must check if it's a singleton or prototype.
                    object advice;
                    if (this.IsSingleton || this.objectFactory.IsSingleton(name))
                    {
                        advice = this.objectFactory.GetObject(name);
                        AssertUtils.ArgumentNotNull(advice, "advice", "object factory returned a null object");
                    }
                    else
                    {
                        advice = new PrototypePlaceholder(name);
                    }
                    AddAdvisorOnChainCreation(advice, name);
                }
            }
        }