/// <summary>
        /// Resolve a reference to another object in the factory.
        /// </summary>
        /// <param name="name">
        /// The name of the object that is having the value of one of its properties resolved.
        /// </param>
        /// <param name="definition">
        /// The definition of the named object.
        /// </param>
        /// <param name="argumentName">
        /// The name of the property the value of which is being resolved.
        /// </param>
        /// <param name="reference">
        /// The runtime reference containing the value of the property.
        /// </param>
        /// <returns>A reference to another object in the factory.</returns>
        protected virtual object ResolveReference(IObjectDefinition definition, string name, string argumentName, RuntimeObjectReference reference)
        {
            #region Instrumentation
            if (log.IsDebugEnabled)
            {
                log.Debug(
                    string.Format(CultureInfo.InvariantCulture, "Resolving reference from property '{0}' in object '{1}' to object '{2}'.",
                                  argumentName, name, reference.ObjectName));
            }
            #endregion

            try
            {
                if (reference.IsToParent)
                {
                    if (null == objectFactory.ParentObjectFactory)
                    {
                        throw new ObjectCreationException(definition.ResourceDescription, name,
                                                          string.Format(
                                                              "Can't resolve reference to '{0}' in parent factory: " + "no parent factory available.",
                                                              reference.ObjectName));
                    }
                    return(objectFactory.ParentObjectFactory.GetObject(reference.ObjectName));
                }
                return(objectFactory.GetObject(reference.ObjectName));
            }
            catch (ObjectsException ex)
            {
                throw ObjectCreationException.GetObjectCreationException(ex, name, argumentName, definition.ResourceDescription, reference.ObjectName);
            }
        }
        /// <summary>
        /// Resolves an inner object definition.
        /// </summary>
        /// <param name="name">
        /// The name of the object that surrounds this inner object definition.
        /// </param>
        /// <param name="innerObjectName">
        /// The name of the inner object definition... note: this is a synthetic
        /// name assigned by the factory (since it makes no sense for inner object
        /// definitions to have names).
        /// </param>
        /// <param name="argumentName">
        /// The name of the property the value of which is being resolved.
        /// </param>
        /// <param name="definition">
        /// The definition of the inner object that is to be resolved.
        /// </param>
        /// <param name="singletonOwner">
        /// <see langword="true"/> if the owner of the property is a singleton.
        /// </param>
        /// <returns>
        /// The resolved object as defined by the inner object definition.
        /// </returns>
        protected virtual object ResolveInnerObjectDefinition(string name, string innerObjectName, string argumentName, IObjectDefinition definition,
                                                              bool singletonOwner)
        {
            RootObjectDefinition mod = objectFactory.GetMergedObjectDefinition(innerObjectName, definition);

            // Check given bean name whether it is unique. If not already unique,
            // add counter - increasing the counter until the name is unique.
            String actualInnerObjectName = innerObjectName;

            if (mod.IsSingleton)
            {
                actualInnerObjectName = AdaptInnerObjectName(innerObjectName);
            }


            mod.IsSingleton = singletonOwner;
            object instance;
            object result;

            try
            {
                //SPRNET-986 ObjectUtils.EmptyObjects -> null
                instance = objectFactory.InstantiateObject(actualInnerObjectName, mod, null, false, false);
                result   = objectFactory.GetObjectForInstance(instance, actualInnerObjectName, actualInnerObjectName, mod);
            }
            catch (ObjectsException ex)
            {
                throw ObjectCreationException.GetObjectCreationException(ex, name, argumentName, definition.ResourceDescription, innerObjectName);
            }
            if (singletonOwner && instance is IDisposable)
            {
                // keep a reference to the inner object instance, to be able to destroy
                // it on factory shutdown...
                objectFactory.DisposableInnerObjects.Add(instance);
            }
            return(result);
        }