Fri Nov 24 18:38:31 CET 2006 Paolo Molaro <lupus@ximian.com>
[mono.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Addressing / ReplyTo.cs
1 //
2 // Microsoft.Web.Services.Addressing.ReplyTo
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 ReplyTo : EndpointReferenceType, IXmlElement
16         {
17
18                 public ReplyTo (Address address) : base (address)
19                 {
20                 }
21                 
22                 public ReplyTo (Uri address) : base (address)
23                 {
24                 }
25
26                 public ReplyTo (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                                                                      "ReplyTo",
39                                                                      "http://schemas.xmlsoap.org/2003/03/addressing");
40                         GetXmlAny (document, element);
41                         return element;
42                 }
43
44                 public void LoadXml (XmlElement element)
45                 {
46                         if(element == null) {
47                                 throw new ArgumentNullException ("element");
48                         }
49
50                         if(element.LocalName != "ReplyTo" || element.NamespaceURI != "http://schemas.xmlsoap.org/2003/03/addressing") {
51                                 throw new ArgumentException ("Invalid Argument Supplied");
52                         }
53
54                         LoadXmlAny (element);
55                 }
56
57                 public static implicit operator ReplyTo (Uri uri)
58                 {
59                         return new ReplyTo (uri);
60                 }
61
62                 public static implicit operator Uri (ReplyTo obj)
63                 {
64                         if(obj == null) {
65                                 return null;
66                         }
67                         return obj.Address.Value;
68                 }
69
70         }
71
72 }