2003-09-30 Todd Berman <tberman@gentoo.org>
[mono.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Addressing / AttributedUriString.cs
1 //
2 // Microsoft.Web.Services.Addressing.AttributedUriString
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 abstract class AttributedUriString : OpenAttributeElement
16         {
17                 
18                 private string _uri;
19
20                 public AttributedUriString () : base ()
21                 {
22                 }
23
24                 public AttributedUriString (string uri)
25                 {
26                         if(uri == null) {
27                                 throw new ArgumentNullException ("uri");
28                         }
29                         _uri = uri;
30                 }
31
32                 public void GetXmlUri (XmlDocument document, XmlElement element)
33                 {
34                         if(element == null) {
35                                 throw new ArgumentNullException ("element");
36                         }
37                         element.InnerText = _uri;
38                         GetXmlAny (document, element);
39                 }
40
41                 public void LoadXmlUri (XmlElement element)
42                 {
43                         if(element == null) {
44                                 throw new ArgumentNullException ("element");
45                         }
46                         ValidateSchema (element);
47                         LoadXmlAny (element);
48                         _uri = element.InnerText;
49                 }
50
51                 public void ValidateSchema (XmlElement element)
52                 {
53                         if(element.ChildNodes.Count >= 2) {
54                                 throw new AddressingFormatException ("wsa_InvalidAttributeUri");
55                         }
56                         if(element.ChildNodes.Count == 1 && !(element.FirstChild is XmlText)) {
57                                 throw new AddressingFormatException ("wsa_InvalidAttributeUri");
58                         }
59                 }
60
61                 public string Value {
62                         get { return _uri; }
63                         set { _uri = value; }
64                 }
65                 
66         }
67
68 }