/// <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); } } }
public override void Init() { outer.Init(); }