2003-10-08 Todd Berman <tberman@gentoo.org>
[mono.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Addressing / From.cs
1 //
2 // Microsoft.Web.Services.Addressing.From.cs
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         public class From : EndpointReferenceType, IXmlElement
15         {
16                 public From (Address address) : base (address)
17                 {
18                 }
19
20                 public From (Uri uri) : base (uri)
21                 {
22                 }
23
24                 public From (XmlElement element) : base ()
25                 {
26                         LoadXml (element);
27                 }
28
29                 public XmlElement GetXml (XmlDocument document)
30                 {
31                         XmlElement element = document.CreateElement ("wsa",
32                                                                      "From",
33                                                                      "http://schemas.xmlsoap.org/2003/03/addressing");
34
35                         GetXmlAny (document, element);
36                         return element;
37                 }
38
39                 public void LoadXml (XmlElement element)
40                 {
41                         if(element == null) {
42                                 throw new ArgumentNullException ("element");
43                         }
44                         if(element.LocalName != "From" || element.LocalName != "http://schemas.xmlsoap.org/2003/03/addressing") {
45                                 throw new ArgumentException ("Invalid Element Supplied");
46                         }
47
48                         LoadXmlAny (element);
49                 }
50
51                 public static implicit operator From (Uri uri)
52                 {
53                         return new From (uri);
54                 }
55
56                 public static implicit operator Uri (From obj)
57                 {
58                         if(obj == null) {
59                                 return null;
60                         }
61                         return obj.Address.Value;
62                 }
63         }
64 }