Pinvoke symbols according to the new moonlight naming convention.
[mono.git] / mcs / class / System.Runtime.Serialization / System.Runtime.Serialization / XmlObjectSerializer.cs
1 //
2 // XmlObjectSerializer.cs
3 //
4 // Author:
5 //      Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2005 Novell, Inc.  http://www.novell.com
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 #if NET_2_0
29 using System;
30 using System.Collections;
31 using System.IO;
32 using System.Reflection;
33 using System.Runtime.Serialization.Formatters.Binary;
34 using System.Xml;
35 using System.Xml.Schema;
36
37 using QName = System.Xml.XmlQualifiedName;
38
39 namespace System.Runtime.Serialization
40 {
41         public abstract class XmlObjectSerializer
42         {
43                 // This is only for compatible mode.
44                 IDataContractSurrogate surrogate;
45
46                 SerializationBinder binder;
47                 ISurrogateSelector selector;
48
49                 int max_items = 0x10000; // FIXME: could be from config.
50
51                 protected XmlObjectSerializer ()
52                 {
53                 }
54
55                 public virtual bool IsStartObject (XmlReader reader)
56                 {
57                         return IsStartObject (XmlDictionaryReader.CreateDictionaryReader (reader));
58                 }
59
60                 public abstract bool IsStartObject (XmlDictionaryReader reader);
61
62                 public virtual object ReadObject (Stream stream)
63                 {
64                         return ReadObject (XmlReader.Create (stream));
65                 }
66
67                 public virtual object ReadObject (XmlReader reader)
68                 {
69                         return ReadObject (XmlDictionaryReader.CreateDictionaryReader (reader));
70                 }
71
72                 public virtual object ReadObject (XmlDictionaryReader reader)
73                 {
74                         return ReadObject (reader, true);
75                 }
76
77                 public virtual object ReadObject (XmlReader reader, bool readContentOnly)
78                 {
79                         return ReadObject (
80                                 XmlDictionaryReader.CreateDictionaryReader (reader),
81                                 readContentOnly);
82                 }
83
84                 [MonoTODO]
85                 public abstract object ReadObject (XmlDictionaryReader reader, bool readContentOnly);
86
87                 public virtual void WriteObject (Stream stream, object graph)
88                 {
89                         using (XmlWriter xw = XmlDictionaryWriter.CreateTextWriter (stream)) {
90                                 WriteObject (xw, graph);
91                         }
92                 }
93
94                 public virtual void WriteObject (XmlWriter writer, object graph)
95                 {
96                         WriteObject (XmlDictionaryWriter.CreateDictionaryWriter (writer), graph);
97                 }
98
99                 public virtual void WriteStartObject (XmlWriter writer, object graph)
100                 {
101                         WriteStartObject (XmlDictionaryWriter.CreateDictionaryWriter (writer), graph);
102                 }
103
104                 public virtual void WriteObject (XmlDictionaryWriter writer, object graph)
105                 {
106                         WriteStartObject (writer, graph);
107                         WriteObjectContent (writer, graph);
108                         WriteEndObject (writer);
109                 }
110
111                 public abstract void WriteStartObject (
112                         XmlDictionaryWriter writer, object graph);
113
114                 public virtual void WriteObjectContent (XmlWriter writer, object graph)
115                 {
116                         WriteObjectContent (
117                                 XmlDictionaryWriter.CreateDictionaryWriter (writer),
118                                 graph);
119                 }
120
121                 public abstract void WriteObjectContent (
122                         XmlDictionaryWriter writer, object graph);
123
124                 public virtual void WriteEndObject (XmlWriter writer)
125                 {
126                         WriteEndObject (XmlDictionaryWriter.CreateDictionaryWriter (writer));
127                 }
128
129                 public abstract void WriteEndObject (
130                         XmlDictionaryWriter writer);
131         }
132 }
133 #endif