2008-09-24 Jb Evain <jbevain@novell.com>
[mono.git] / mcs / class / corlib / System.Runtime.Remoting.Metadata.W3cXsd2001 / SoapQName.cs
1 //
2 // System.Runtime.Remoting.Metadata.W3cXsd2001.SoapQName.cs
3 //
4 // Authors:
5 //      Martin Willemoes Hansen (mwh@sysrq.dk)
6 //      Lluis Sanchez Gual (lluis@ximian.com)
7 //
8 // (C) 2003 Martin Willemoes Hansen
9 //
10
11 //
12 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
13 //
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
21 // 
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
24 // 
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 //
33
34 using System;
35
36 namespace System.Runtime.Remoting.Metadata.W3cXsd2001 
37 {
38         [Serializable]
39 #if NET_2_0
40         [System.Runtime.InteropServices.ComVisible (true)]
41 #endif
42         public sealed class SoapQName : ISoapXsd
43         {
44                 string _name;
45                 string _key;
46                 string _namespace;
47                 
48                 public SoapQName ()
49                 {
50                 }
51
52                 public SoapQName (string value)
53                 {
54                         _name = value;
55                 }
56
57                 public SoapQName (string key, string name)
58                 {
59                         _key = key;
60                         _name = name;
61                 }
62
63                 public SoapQName (string key, string name, string namespaceValue)
64                 {
65                         _key = key;
66                         _name = name;
67                         _namespace = namespaceValue;
68                 }
69
70                 public string Key {
71                         get { return _key; } 
72                         set { _key = value; }
73                 }
74
75                 public string Name {
76                         get { return _name; } 
77                         set { _name = value; }
78                 }
79
80                 public string Namespace {
81                         get { return _namespace; } 
82                         set { _namespace = value; }
83                 }
84
85                 public static string XsdType {
86                         get { return "QName"; }
87                 }
88
89                 public string GetXsdType()
90                 {
91                         return XsdType;
92                 }
93                 
94                 public static SoapQName Parse (string value)
95                 {
96                         SoapQName res = new SoapQName ();
97                         int i = value.IndexOf (':');
98                         if (i != -1)
99                         {
100                                 res.Key = value.Substring (0,i);
101                                 res.Name = value.Substring (i+1);
102                         }
103                         else
104                                 res.Name = value;
105                         return res;
106                 }
107
108                 public override string ToString()
109                 {
110                         if (_key == null || _key == "") return _name;
111                         else return _key + ":" + _name;
112                 }
113         }
114 }