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