2 // Microsoft.Web.Services.Addressing.RelatesTo.cs
4 // Author: Todd Berman <tberman@gentoo.org>
6 // (C) 2003 Todd Berman
10 using Microsoft
.Web
.Services
.Xml
;
12 namespace Microsoft
.Web
.Services
.Addressing
14 public class RelatesTo
: AttributedUri
, IXmlElement
16 private QualifiedName _type
;
18 public RelatesTo (XmlElement element
) : base ()
20 _type
= new QualifiedName ("wsa",
22 "http://schemas.xmlsoap.org/ws/2003/03/addressing");
26 public RelatesTo (Uri uri
) : base (uri
)
28 _type
= new QualifiedName ("wsa",
30 "http://schemas.xmlsoap.org/ws/2003/03/addressing");
32 throw new ArgumentNullException ("related");
36 public XmlElement
GetXml (XmlDocument document
)
38 if(document
== null) {
39 throw new ArgumentNullException ("related");
41 XmlElement element
= document
.CreateElement ("wsa",
43 "http://schemas.xmlsoap.org/ws/2003/03/addressing");
45 XmlAttribute attrib
= document
.CreateAttribute ("RelationshipType");
47 attrib
.Value
= _type
.Value
;
49 element
.Attributes
.Append (attrib
);
51 if(_type
.Namespace
!= "http://schemas.xmlsoap.org/ws/2003/03/addressing") {
52 element
.Attributes
.Append (_type
.GetNamespaceDecl (document
));
56 GetXmlUri (document
, element
);
60 public void LoadXml (XmlElement element
)
63 throw new ArgumentNullException ("element");
66 if(element
.LocalName
!= "RelatesTo" || element
.NamespaceURI
!= "http://schemas.xmlsoap.org/ws/2003/03/addressing") {
67 throw new ArgumentException ("Invalid Element Supplied");
70 ValidateSchema (element
);
72 _type
= new QualifiedName ("wsa",
74 "http://schemas.xmlsoap.org/ws/2003/03/addressing");
76 foreach(XmlAttribute attrib
in element
.Attributes
) {
77 if(attrib
.LocalName
== "RelationshipType") {
78 _type
= QualifiedName
.FromString (attrib
.InnerText
, element
);
80 AnyAttributes
.Add (attrib
);
84 Value
= new Uri (element
.InnerText
);
88 public static implicit operator RelatesTo (Uri uri
)
90 return new RelatesTo (uri
);
93 public static implicit operator Uri (RelatesTo obj
)