-
Notifications
You must be signed in to change notification settings - Fork 2
/
DictionaryNamespaceManager.cs
51 lines (44 loc) · 1.29 KB
/
DictionaryNamespaceManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using NullGuard;
namespace Nancy.Rdf
{
/// <summary>
/// Dictionary-backed <see cref="INamespaceManager"/>
/// </summary>
internal class DictionaryNamespaceManager : INamespaceManager
{
private readonly IDictionary<string, Uri> _namespaces;
/// <summary>
/// Initializes a new instance of the <see cref="DictionaryNamespaceManager"/> class.
/// </summary>
public DictionaryNamespaceManager()
{
_namespaces = new Dictionary<string, Uri>();
}
/// <inheritdoc />
public Uri BaseUri { get; private set; }
/// <inheritdoc />
public IEnumerator<NamespaceMap> GetEnumerator()
{
return _namespaces.Select(p => new NamespaceMap(p.Key, p.Value)).GetEnumerator();
}
/// <inheritdoc />
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
/// <inheritdoc />
public void AddNamespace(string prefix, Uri ns)
{
_namespaces.Add(prefix, ns);
}
/// <inheritdoc />
public void SetBaseUri([AllowNull] Uri baseUri)
{
BaseUri = baseUri;
}
}
}