~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.Completion/XmlNamespacePrefixMap.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
// XmlNamespaceMap.cs
 
3
//  
 
4
// Author:
 
5
//       Michael Hutchinson <mhutchinson@novell.com>
 
6
// 
 
7
// Copyright (c) 2011 Novell, Inc.
 
8
// 
 
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
10
// of this software and associated documentation files (the "Software"), to deal
 
11
// in the Software without restriction, including without limitation the rights
 
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
13
// copies of the Software, and to permit persons to whom the Software is
 
14
// furnished to do so, subject to the following conditions:
 
15
// 
 
16
// The above copyright notice and this permission notice shall be included in
 
17
// all copies or substantial portions of the Software.
 
18
// 
 
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
25
// THE SOFTWARE.
 
26
 
 
27
using System;
 
28
using System.Collections.Generic;
 
29
 
 
30
namespace MonoDevelop.XmlEditor.Completion
 
31
{
 
32
        public class XmlNamespacePrefixMap
 
33
        {
 
34
                Dictionary<string,string> pfNsMap = new Dictionary<string,string> ();
 
35
                Dictionary<string,string> nsPfMap = new Dictionary<string,string> ();
 
36
                
 
37
                /// <summary>Gets the prefix registered for the namespace, empty if it's 
 
38
                /// the default namespace, or null if it's not registered.</summary>
 
39
                public string GetPrefix (string ns)
 
40
                {
 
41
                        string prefix;
 
42
                        if (nsPfMap.TryGetValue (ns, out prefix))
 
43
                                return prefix;
 
44
                        return null;
 
45
                }
 
46
                
 
47
                /// <summary>Gets the namespace registered for prefix, or default namespace if prefix is empty.</summary>
 
48
                public string GetNamespace (string prefix)
 
49
                {
 
50
                        string ns;
 
51
                        if (pfNsMap.TryGetValue (prefix, out ns))
 
52
                                return ns;
 
53
                        return null;
 
54
                }
 
55
                
 
56
                /// <summary>Registers a namespace for a prefix, or the default namespace if the prefix is empty.</summary>
 
57
                public void AddPrefix (string ns, string prefix)
 
58
                {
 
59
                        nsPfMap[ns] = prefix;
 
60
                        pfNsMap[prefix] = ns;
 
61
                }
 
62
        }
 
63
}
 
64