Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/SharpVectorCore/Utils/Xml/DynamicXmlNamespaceManager.cs @ 13847

Last change on this file since 13847 was 12762, checked in by aballeit, 10 years ago

#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)

File size: 1.9 KB
Line 
1using System.Xml;
2
3namespace SharpVectors.Xml
4{
5    /// <summary>
6    /// XML namespace manager allowing to fire events when namespace is not found
7    /// </summary>
8    public sealed class DynamicXmlNamespaceManager : XmlNamespaceManager
9    {
10        /// <summary>
11        /// Event handler type
12        /// </summary>
13        public delegate string ResolveEventHandler(string prefix);
14
15        /// <summary>
16        /// Occurs when trying to resolve an unknown namespace.
17        /// </summary>
18        public event ResolveEventHandler Resolve;
19
20        /// <summary>
21        /// Initializes a new instance of the <see cref="DynamicXmlNamespaceManager"/> class.
22        /// </summary>
23        public DynamicXmlNamespaceManager()
24            : base(new NameTable())
25        {
26        }
27
28        /// <summary>
29        /// Initializes a new instance of the <see cref="DynamicXmlNamespaceManager"/> class.
30        /// </summary>
31        /// <param name="xmlNameTable">The XML name table.</param>
32        public DynamicXmlNamespaceManager(XmlNameTable xmlNameTable)
33            : base(xmlNameTable)
34        {
35        }
36
37        /// <summary>
38        /// Gets the namespace URI for the specified prefix.
39        /// </summary>
40        /// <param name="prefix">The prefix whose namespace URI you want to resolve. To match the default namespace, pass String.Empty.</param>
41        /// <returns>
42        /// Returns the namespace URI for <paramref name="prefix"/> or null if there is no mapped namespace. The returned string is atomized.
43        /// For more information on atomized strings, see <see cref="T:System.Xml.XmlNameTable"/>.
44        /// </returns>
45        public override string LookupNamespace(string prefix)
46        {
47            string uri = base.LookupNamespace(prefix);
48            if (uri == null)
49                uri = this.Resolve(prefix);
50
51            return uri;
52        }
53    }
54}
Note: See TracBrowser for help on using the repository browser.