2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Addressing / FaultTo.cs
1 //
2 // Microsoft.Web.Services.Addressing.FaultTo.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 FaultTo : EndpointReferenceType, IXmlElement
15         {
16                 public FaultTo (Address address) : base (address)
17                 {
18                 }
19
20                 public FaultTo (Uri uri) : base (uri)
21                 {
22                 }
23
24                 public FaultTo (XmlElement element) : base ()
25                 {
26                         LoadXml (element);
27                 }
28
29                 public XmlElement GetXml (XmlDocument document)
30                 {
31                         XmlElement element = document.CreateElement ("wsa",
32                                                                      "FaultTo",
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 != "FaultTo" || element.NamespaceURI != "http://schemas.xmlsoap.org/2003/03/addressing") {
45                                 throw new ArgumentException ("Invalid Element Supplied");
46                         }
47                         LoadXmlAny (element);
48                 }
49
50                 public static implicit operator FaultTo (Uri uri)
51                 {
52                         return new FaultTo (uri);
53                 }
54
55                 public static implicit operator Uri (FaultTo obj)
56                 {
57                         if(obj == null) {
58                                 return null;
59                         }
60                         return obj.Address.Value;
61                 }
62         }
63 }