2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Addressing / Action.cs
1 //
2 // Microsoft.Web.Services.Addressing.Action.cs
3 //
4 // Author: Todd Berman <tberman@gentoo.org>
5 //
6 // (C) 2003 Todd Berman
7 //
8
9 using System;
10 using System.Xml;
11 using Microsoft.Web.Services.Xml;
12
13 namespace Microsoft.Web.Services.Addressing
14 {
15
16         public class Action : AttributedUriString, IXmlElement
17         {
18
19
20                 public Action (string uri) : base (uri)
21                 {
22                 }
23
24                 public Action (XmlElement element) : base ()
25                 {
26                         LoadXml (element);
27                 }
28
29                 public static implicit operator Action(string obj)
30                 {
31
32                         return new Action (obj);
33                 
34                 }
35
36                 public static implicit operator string(Action obj)
37                 {
38
39                         if(obj == null) {
40                                 return null;
41                         }
42                         return obj.Value;
43                 
44                 }
45
46                 public XmlElement GetXml (XmlDocument document)
47                 {
48                         if(document == null) {
49                                 throw new ArgumentNullException ("document");
50                         }
51
52                         XmlElement element = document.CreateElement ("wsa",
53                                                                      "Action",
54                                                                      "http://schemas.xmlsoap.org/ws/2003/03/addressing");
55                         
56                         GetXmlUri (document, element);
57                         
58                         return element;
59                         
60                 }
61
62                 public void LoadXml (XmlElement element)
63                 {
64                         if(element == null) {
65                                 throw new ArgumentNullException ("element");
66                         }
67
68                         if(element.LocalName != "Action" || element.NamespaceURI != "http://schemas.xmlsoap.org/ws/2003/03/addressing") {
69                                 throw new ArgumentException ("Invalid Element Supplied");
70                         }
71
72                         LoadXmlUri (element);
73                 }               
74
75         }
76 }