/// <summary>
        /// Associates a parser with a namespace.
        /// </summary>
        /// <remarks>
        /// <note>
        /// Parsers registered with the same <paramref name="namespaceUri"/> as that
        /// of a parser that has previously been registered will overwrite the existing
        /// parser.
        /// </note>
        /// </remarks>
        /// <param name="parserType">
        /// The <see cref="System.Type"/> of the parser that will be activated
        /// when the attendant <paramref name="namespaceUri"/> is
        /// encountered.
        /// </param>
        /// <param name="namespaceUri">
        /// The namespace with which to associate instance of the parser.
        /// </param>
        /// <param name="schemaLocation">
        /// The location of the XML schema that should be used for validation
        /// of the XML elements that belong to the specified namespace
        /// (can be any valid Spring.NET resource URI).
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// If the <paramref name="parserType"/> is not a <see cref="System.Type"/>
        /// that implements the <see cref="INamespaceParser"/>
        /// interface.
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="parserType"/> is <see langword="null"/>.
        /// </exception>
        public static void RegisterParser(Type parserType, string namespaceUri, string schemaLocation)
        {
            AssertUtils.ArgumentNotNull(parserType, "parserType");

            INamespaceParser np = null;

            if ((typeof(INamespaceParser)).IsAssignableFrom(parserType))
            {
                np = (INamespaceParser)ObjectUtils.InstantiateType(parserType);
            }
            // TODO (EE): workaround to enable smooth transition between 1.x and 2.0 style namespace handling
            else if (typeof(IObjectDefinitionParser).IsAssignableFrom(parserType))
            {
                // determine and use defaults for the namespace and schema location, if necessary
                if (StringUtils.IsNullOrEmpty(namespaceUri) || StringUtils.IsNullOrEmpty(schemaLocation))
                {
                    NamespaceParserAttribute defaults = GetDefaults(parserType);
                    if (defaults == null)
                    {
                        throw new ArgumentNullException(
                                  "Either default or an explicit namespace value must be specified for a configuration parser.");
                    }

                    if (StringUtils.IsNullOrEmpty(namespaceUri))
                    {
                        namespaceUri = defaults.Namespace;
                    }

                    if (StringUtils.IsNullOrEmpty(schemaLocation))
                    {
                        schemaLocation = defaults.SchemaLocation;
                        if (defaults.SchemaLocationAssemblyHint != null)
                        {
                            schemaLocation =
                                GetAssemblySchemaLocation(defaults.SchemaLocationAssemblyHint, schemaLocation);
                        }
                    }
                }

                IObjectDefinitionParser odParser = (IObjectDefinitionParser)ObjectUtils.InstantiateType(parserType);
                np = new ObjectDefinitionParserNamespaceParser(odParser);
            }
            else
            {
                throw new ArgumentException(
                          string.Format("The [{0}] Type must implement the INamespaceParser interface.", parserType.Name)
                          , "parserType");
            }

            RegisterParser(np, namespaceUri, schemaLocation);
        }
        /// <summary>
        /// Associates a parser with a namespace.
        /// </summary>
        /// <remarks>
        /// <note>
        /// Parsers registered with the same <paramref name="namespaceUri"/> as that
        /// of a parser that has previously been registered will overwrite the existing
        /// parser.
        /// </note>
        /// </remarks>
        /// <param name="namespaceUri">
        /// The namespace with which to associate instance of the parser.
        /// </param>
        /// <param name="parser">
        /// The parser instance.
        /// </param>
        /// <param name="schemaLocation">
        /// The location of the XML schema that should be used for validation
        /// of the XML elements that belong to the specified namespace
        /// (can be any valid Spring.NET resource URI).
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="parser"/> is <see langword="null"/>, or if
        /// <paramref name="namespaceUri"/> is not specified and parser class
        /// does not have default value defined using <see cref="NamespaceParserAttribute"/>.
        /// </exception>
        public static void RegisterParser(INamespaceParser parser, string namespaceUri, string schemaLocation)
        {
            AssertUtils.ArgumentNotNull(parser, "parser");

            // determine and use defaults for the namespace and schema location, if necessary
            if (StringUtils.IsNullOrEmpty(namespaceUri) || StringUtils.IsNullOrEmpty(schemaLocation))
            {
                NamespaceParserAttribute defaults = GetDefaults(parser.GetType());
                if (defaults == null)
                {
                    throw new ArgumentNullException(
                              "Either default or an explicit namespace value must be specified for a configuration parser.");
                }

                if (StringUtils.IsNullOrEmpty(namespaceUri))
                {
                    namespaceUri = defaults.Namespace;
                }

                if (StringUtils.IsNullOrEmpty(schemaLocation))
                {
                    schemaLocation = defaults.SchemaLocation;
                    if (defaults.SchemaLocationAssemblyHint != null)
                    {
                        schemaLocation = GetAssemblySchemaLocation(defaults.SchemaLocationAssemblyHint, schemaLocation);
                    }
                }
            }

            // initialize the parser
            parser.Init();

            // register parser
            lock (parsers.SyncRoot)
                lock (schemas)
                {
                    parsers[namespaceUri] = parser;
                    if (StringUtils.HasText(schemaLocation) && !schemas.Contains(namespaceUri))
                    {
                        RegisterSchema(namespaceUri, schemaLocation);
                    }
                }
        }