/// <summary>
        /// Attempt to release the given object.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="oldObject"></param>
        public void Release <T>(T oldObject)
        {
            Type type = typeof(T);

            if (Logger != null)
            {
                Logger.Trace("Attempting to release object of type " + type.Name);
            }
            if (ReleaseMapping.ContainsKey(type))
            {
                ReleaseMapping[type].Invoke(this, oldObject);
            }
            else
            {
                if (Logger != null)
                {
                    Logger.Debug("There is no method to release objects of type " + type.Name + ". Ignoring.");
                }
            }
        }
        /// <summary>
        /// Adopt the given new factory's create/release routines and settings and merge it with our own.
        /// Fails with InvalidOperationException if there are duplicate definitions.
        /// </summary>
        /// <param name="newFactory"></param>
        public void MergeWithSelf(DIFactory newFactory)
        {
            //For each container, merge the creation mappings
            foreach (var cMapping in newFactory.CreationMapping)
            {
                if (CreationMapping.ContainsKey(cMapping.Key))
                {
                    throw new InvalidOperationException("Duplicate methods for creating type " + cMapping.Key.ToString());
                }
                else
                {
                    CreationMapping.Add(cMapping.Key, cMapping.Value);
                }
            }

            //For each container, merge the release mappings
            foreach (var rMapping in newFactory.ReleaseMapping)
            {
                if (ReleaseMapping.ContainsKey(rMapping.Key))
                {
                    throw new InvalidOperationException("Duplicate methods for releasing type " + rMapping.Key.ToString());
                }
                else
                {
                    ReleaseMapping.Add(rMapping.Key, rMapping.Value);
                }
            }

            //Finally, for each container, merge the settings.
            foreach (var setting in newFactory.Settings)
            {
                if (Settings.ContainsKey(setting.Key))
                {
                    throw new InvalidOperationException("Duplicate settings key: " + setting.Key);
                }
                else
                {
                    Settings.Add(setting.Key, setting.Value);
                }
            }
        }