b91bfef67ba2c7e068550b78d621315631d187cb
[mono.git] / mcs / class / System.Web.Services / System.Web.Services.Protocols / SoapHeader.cs
1 // \r
2 // System.Web.Services.Protocols.SoapHeader.cs\r
3 //\r
4 // Author:\r
5 //   Tim Coleman (tim@timcoleman.com)\r
6 //\r
7 // Copyright (C) Tim Coleman, 2002\r
8 //\r
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 \r
31 using System.ComponentModel;\r
32 using System.Xml.Serialization;
33 using System.Xml;\r
34 \r
35 namespace System.Web.Services.Protocols {\r
36         [SoapType (IncludeInSchema = false)]\r
37         [XmlType (IncludeInSchema = false)]\r
38         public abstract class SoapHeader {\r
39 \r
40                 #region Fields\r
41 \r
42                 string actor;\r
43                 bool didUnderstand;\r
44                 bool mustUnderstand;\r
45                 \r
46 #if NET_2_0\r
47                 string role;\r
48                 bool relay;\r
49 #endif\r
50 \r
51                 #endregion // Fields\r
52 \r
53                 #region Constructors\r
54 \r
55                 protected SoapHeader ()\r
56                 {\r
57                         actor = String.Empty; \r
58                         didUnderstand = false;\r
59                         mustUnderstand = false;\r
60                 }\r
61 \r
62                 internal SoapHeader (XmlElement elem)\r
63                 {\r
64                         actor = elem.GetAttribute ("actor", "http://schemas.xmlsoap.org/soap/envelope/");
65                         string me = elem.GetAttribute ("mustUnderstand", "http://schemas.xmlsoap.org/soap/envelope/");\r
66                         if (me != "") EncodedMustUnderstand = me;\r
67                 }\r
68 \r
69                 #endregion // Constructors\r
70 \r
71                 #region Properties\r
72 \r
73                 [DefaultValue ("")]\r
74                 [SoapAttribute ("actor", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]\r
75                 [XmlAttribute ("actor", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]\r
76                 public string Actor {   \r
77                         get { return actor; }\r
78                         set { actor = value; }\r
79                 }\r
80 \r
81                 [SoapIgnore]\r
82                 [XmlIgnore]\r
83                 public bool DidUnderstand {\r
84                         get { return didUnderstand; }\r
85                         set { didUnderstand = value; }\r
86                 }\r
87 \r
88                 [DefaultValue ("0")]\r
89                 [SoapAttribute ("mustUnderstand", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]\r
90                 [XmlAttribute ("mustUnderstand", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]\r
91                 public string EncodedMustUnderstand {\r
92                         get { return (MustUnderstand ? "1" : "0"); }\r
93                         set {   \r
94                                 if (value == "true" || value == "1") \r
95                                         MustUnderstand = true;\r
96                                 else if (value == "false" || value == "0")\r
97                                         MustUnderstand = false;\r
98                                 else\r
99                                         throw new ArgumentException ();\r
100                         }\r
101                 }\r
102 \r
103                 [SoapIgnore]\r
104                 [XmlIgnore]\r
105                 public bool MustUnderstand {\r
106                         get { return mustUnderstand; }\r
107                         set { mustUnderstand = value; }\r
108                 }\r
109                 \r
110 #if NET_2_0\r
111 \r
112                 [DefaultValue ("0")]\r
113                 [SoapAttribute ("mustUnderstand", Namespace = "http://www.w3.org/2003/05/soap-envelope")]\r
114                 [XmlAttribute ("mustUnderstand", Namespace = "http://www.w3.org/2003/05/soap-envelope")]\r
115                 [System.Runtime.InteropServices.ComVisible(false)]\r
116                 public string EncodedMustUnderstand12 {\r
117                         get { return (MustUnderstand ? "1" : "0"); }\r
118                         set {   \r
119                                 if (value == "true" || value == "1") \r
120                                         MustUnderstand = true;\r
121                                 else if (value == "false" || value == "0")\r
122                                         MustUnderstand = false;\r
123                                 else\r
124                                         throw new ArgumentException ();\r
125                         }\r
126                 }\r
127 \r
128                 [DefaultValue ("0")]\r
129                 [SoapAttribute ("relay", Namespace = "http://www.w3.org/2003/05/soap-envelope")]\r
130                 [XmlAttribute ("relay", Namespace = "http://www.w3.org/2003/05/soap-envelope")]\r
131                 [System.Runtime.InteropServices.ComVisible(false)]\r
132                 public string EncodedRelay\r
133                 {\r
134                         get { return (Relay ? "1" : "0"); }\r
135                         set {   \r
136                                 if (value == "true" || value == "1") \r
137                                         Relay = true;\r
138                                 else if (value == "false" || value == "0")\r
139                                         Relay = false;\r
140                                 else\r
141                                         throw new ArgumentException ();\r
142                         }\r
143                 }\r
144                 \r
145                 [SoapIgnore]\r
146                 [XmlIgnore]\r
147                 [System.Runtime.InteropServices.ComVisible(false)]\r
148                 public bool Relay {\r
149                         get { return relay; }\r
150                         set { relay = value; }\r
151                 }\r
152                 \r
153                 [DefaultValue ("")]\r
154                 [SoapAttribute ("role", Namespace = "http://www.w3.org/2003/05/soap-envelope")]\r
155                 [XmlAttribute ("role", Namespace = "http://www.w3.org/2003/05/soap-envelope")]\r
156                 [System.Runtime.InteropServices.ComVisible(false)]\r
157                 public string Role {\r
158                         get { return role; }\r
159                         set { role = value; }\r
160                 }\r
161                 \r
162 #endif\r
163 \r
164                 #endregion // Properties\r
165         }\r
166 }\r