* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Addressing / AttributedUri.cs
1 //
2 // Microsoft.Web.Services.Addressing.AttributedUri
3 //
4 // Author: Todd Berman <tberman@gentoo.org>
5 //
6 // (C) 2003 Todd Berman
7
8 using System;
9 using System.Net;
10 using System.Xml;
11 using Microsoft.Web.Services.Xml;
12
13 namespace Microsoft.Web.Services.Addressing
14 {
15
16         public abstract class AttributedUri : OpenAttributeElement
17         {
18
19                 private Uri _value;
20
21                 public AttributedUri (Uri uri) : base ()
22                 {
23                         if(uri == null) {
24                                 throw new ArgumentNullException ("uri");
25                         }
26
27                         _value = uri;
28                 }
29
30                 public AttributedUri (AttributedUri aUri) : base ()
31                 {
32
33                         _value = aUri.Value;
34
35                         foreach (XmlAttribute attribute in aUri.AnyAttributes) {
36
37                                 AnyAttributes.Add (attribute);
38
39                         }
40
41                 }
42
43                 public AttributedUri () : base ()
44                 {
45                 }
46
47                 public void GetXmlUri (XmlDocument document, XmlElement element)
48                 {
49                         if(element == null) {
50                                 throw new ArgumentNullException ("element");
51                         }
52
53                         element.InnerText = _value.ToString();
54
55                         GetXmlAny(document, element);
56                 }
57
58                 public void LoadXmlUri (XmlElement element)
59                 {
60                         if(element == null) {
61                                 throw new ArgumentNullException ("element");
62                         }
63
64                         ValidateSchema (element);
65
66                         LoadXmlAny (element);
67
68                         _value = new Uri(element.InnerText);
69
70                 }
71
72                 public void ValidateSchema (XmlElement element)
73                 {
74                         if(element.ChildNodes.Count > 1) {
75                                 throw new AddressingFormatException ("wsa_InvalidAttributeUri");
76                         }
77                         if(element.ChildNodes.Count == 1 && !(element.FirstChild is XmlText)) {
78                                 throw new AddressingFormatException ("wsa_InvalidAttributeUri");
79                         }
80                 }
81
82                 public Uri Value {
83                         get { return _value; }
84                         set { _value = value; }
85                 } 
86
87         }
88
89 }