/// <summary> /// Parses list of library assemblies. /// </summary> /// <param name="node">Node containing the list.</param> /// <param name="libraries">List of libraries to be modified by given <paramref name="node"/>.</param> /// <param name="extensionsPath">Full path to the extensions directory.</param> /// <param name="librariesPath">Full path to the libraries directory.</param> /// <remarks> /// The following node type is allowed to be contained in the <paramref name="node"/>: /// <code> /// <add assembly="{string}" [section="{string}"] {additional attributes specific to library} /> /// </code> /// </remarks> public static void ParseLibraryAssemblyList(XmlNode/*!*/ node, LibrariesConfigurationList/*!*/ libraries, FullPath extensionsPath, FullPath librariesPath) { if (node == null) throw new ArgumentNullException("node"); if (libraries == null) throw new ArgumentNullException("libraries"); foreach (XmlNode child in node.ChildNodes) { if (child.Name == "add" || child.Name == "remove") { if (!Configuration.IsValidInCurrentScope(child)) continue; string assembly_name = ConfigUtils.OptionalAttribute(child, "assembly"); string library_name = ConfigUtils.OptionalAttribute(child, "library"); string extension_name = ConfigUtils.OptionalAttribute(child, "extension"); string url = ConfigUtils.OptionalAttribute(child, "url"); string section_name = ConfigUtils.OptionalAttribute(child, "section"); Uri uri = null; if (assembly_name == null && url == null && extension_name == null && library_name == null) throw new ConfigurationErrorsException(CoreResources.GetString("missing_attribute", "assembly"), child); if (library_name != null) { try { uri = new Uri("file:///" + Path.Combine(librariesPath.IsEmpty ? "" : librariesPath, library_name + ".dll")); } catch (UriFormatException) { throw new InvalidAttributeValueException(child, "library"); } } if (extension_name != null) { try { uri = new Uri("file:///" + Externals.GetWrapperPath(extension_name, extensionsPath.IsEmpty ? "" : extensionsPath)); } catch (UriFormatException) { throw new InvalidAttributeValueException(child, "extension"); } } if (url != null) { try { uri = GetUri(node, url); } catch (UriFormatException) { throw new InvalidAttributeValueException(child, "url"); } } if (child.Name == "add") libraries.AddLibrary(assembly_name, uri, section_name, child); else if (child.Name == "remove") libraries.RemoveLibrary(assembly_name, uri); else Debug.Fail(); } else if (child.Name == "clear") { libraries.ClearLibraries(); } else if (child.NodeType == XmlNodeType.Element) { throw new ConfigUtils.InvalidNodeException(child); } } }