New test.
[mono.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Xml / OpenElement.cs
1 //
2 // Microsoft.Web.Services.Xml.OpenElement.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 System.Collections;
11
12 namespace Microsoft.Web.Services.Xml
13 {
14
15         public abstract class OpenElement
16         {
17                 private ArrayList _anyAttribute;
18                 private ArrayList _anyElement;
19
20                 public OpenElement ()
21                 {
22                         _anyAttribute = new ArrayList ();
23                         _anyElement = new ArrayList ();
24                 }
25
26                 protected virtual void GetXmlAny (XmlDocument document, XmlElement element)
27                 {
28                         if(document == null) {
29                                 throw new ArgumentNullException ("document");
30                         }
31                         if(element == null) {
32                                 throw new ArgumentNullException ("element");
33                         }
34
35                         foreach(XmlAttribute attrib in AnyAttributes) {
36                                 element.Attributes.Append ((XmlAttribute) document.ImportNode (attrib, true));
37                         }
38
39                         foreach(XmlElement elem in AnyElements) {
40                                 element.AppendChild (document.ImportNode (elem, true));
41                         }
42                 }
43
44                 protected virtual void LoadXmlAny (XmlElement element)
45                 {
46                         if(element == null) {
47                                 throw new ArgumentNullException ("element");
48                         }
49
50                         foreach(XmlAttribute attrib in element.Attributes) {
51                                 AnyAttributes.Add (attrib);
52                         }
53
54                         foreach(XmlElement elem in element.ChildNodes) {
55                                 AnyElements.Add (elem);
56                         }
57                 }
58
59                 public IList AnyAttributes {
60                         get { return _anyAttribute; }
61                 }
62
63                 public IList AnyElements {
64                         get { return _anyElement; }
65                 }
66         }
67
68 }