2009-04-03 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System.ServiceModel.Web / System.ServiceModel.Syndication / ServiceDocumentFormatter.cs
1 //
2 // ServiceDocumentFormatter.cs
3 //
4 // Author:
5 //      Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2009 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 using System;
29 using System.Collections.Generic;
30 using System.IO;
31 using System.Runtime.Serialization;
32 using System.ServiceModel;
33 using System.ServiceModel.Channels;
34 using System.Xml;
35
36 namespace System.ServiceModel.Syndication
37 {
38         [DataContract]
39         public abstract class ServiceDocumentFormatter
40         {
41                 [MonoTODO]
42                 protected static SyndicationCategory CreateCategory (InlineCategoriesDocument inlineCategories)
43                 {
44                         throw new NotImplementedException ();
45                 }
46
47                 [MonoTODO]
48                 protected static ResourceCollectionInfo CreateCollection (Workspace workspace)
49                 {
50                         throw new NotImplementedException ();
51                 }
52
53                 [MonoTODO]
54                 protected static InlineCategoriesDocument CreateInlineCategories (ResourceCollectionInfo collection)
55                 {
56                         throw new NotImplementedException ();
57                 }
58
59                 [MonoTODO]
60                 protected static ReferencedCategoriesDocument CreateReferencedCategories (ResourceCollectionInfo collection)
61                 {
62                         throw new NotImplementedException ();
63                 }
64
65                 [MonoTODO]
66                 protected static Workspace CreateWorkspace (ServiceDocument document)
67                 {
68                         throw new NotImplementedException ();
69                 }
70
71                 [MonoTODO]
72                 protected static void LoadElementExtensions (XmlReader reader, CategoriesDocument categories, int maxExtensionSize)
73                 {
74                         throw new NotImplementedException ();
75                 }
76
77                 [MonoTODO]
78                 protected static void LoadElementExtensions (XmlReader reader,ResourceCollectionInfo collection, int maxExtensionSize)
79                 {
80                         throw new NotImplementedException ();
81                 }
82
83                 [MonoTODO]
84                 protected static void LoadElementExtensions (XmlReader reader, ServiceDocument document, int maxExtensionSize)
85                 {
86                         throw new NotImplementedException ();
87                 }
88
89                 [MonoTODO]
90                 protected static void LoadElementExtensions (XmlReader reader, Workspace workspace, int maxExtensionSize)
91                 {
92                         throw new NotImplementedException ();
93                 }
94
95                 [MonoTODO]
96                 protected static bool TryParseAttribute (string name, string ns, string value, CategoriesDocument categories, string version)
97                 {
98                         throw new NotImplementedException ();
99                 }
100
101                 [MonoTODO]
102                 protected static bool TryParseAttribute (string name, string ns, string value, ResourceCollectionInfo collection, string version)
103                 {
104                         throw new NotImplementedException ();
105                 }
106
107                 [MonoTODO]
108                 protected static bool TryParseAttribute (string name, string ns, string value, ServiceDocument document, string version)
109                 {
110                         throw new NotImplementedException ();
111                 }
112
113                 [MonoTODO]
114                 protected static bool TryParseAttribute (string name, string ns, string value, Workspace workspace, string version)
115                 {
116                         throw new NotImplementedException ();
117                 }
118
119                 [MonoTODO]
120                 protected static bool TryParseElement (XmlReader reader, CategoriesDocument categories, string version)
121                 {
122                         throw new NotImplementedException ();
123                 }
124
125                 [MonoTODO]
126                 protected static bool TryParseElement (XmlReader reader, ResourceCollectionInfo collection, string version)
127                 {
128                         throw new NotImplementedException ();
129                 }
130
131                 [MonoTODO]
132                 protected static bool TryParseElement (XmlReader reader, ServiceDocument document, string version)
133                 {
134                         throw new NotImplementedException ();
135                 }
136
137                 [MonoTODO]
138                 protected static bool TryParseElement (XmlReader reader, Workspace workspace, string version)
139                 {
140                         throw new NotImplementedException ();
141                 }
142
143                 protected static void WriteAttributeExtensions (XmlWriter writer, CategoriesDocument categories, string version)
144                 {
145                         Utility.WriteAttributeExtensions (categories.AttributeExtensions, writer, version);
146                 }
147
148                 protected static void WriteAttributeExtensions (XmlWriter writer, ResourceCollectionInfo collection, string version)
149                 {
150                         Utility.WriteAttributeExtensions (collection.AttributeExtensions, writer, version);
151                 }
152
153                 protected static void WriteAttributeExtensions (XmlWriter writer, ServiceDocument document, string version)
154                 {
155                         Utility.WriteAttributeExtensions (document.AttributeExtensions, writer, version);
156                 }
157
158                 protected static void WriteAttributeExtensions (XmlWriter writer, Workspace workspace, string version)
159                 {
160                         Utility.WriteAttributeExtensions (workspace.AttributeExtensions, writer, version);
161                 }
162
163                 protected static void WriteElementExtensions (XmlWriter writer, CategoriesDocument categories, string version)
164                 {
165                         Utility.WriteElementExtensions (categories.ElementExtensions, writer, version);
166                 }
167
168                 protected static void WriteElementExtensions (XmlWriter writer, ResourceCollectionInfo collection, string version)
169                 {
170                         Utility.WriteElementExtensions (collection.ElementExtensions, writer, version);
171                 }
172
173                 protected static void WriteElementExtensions (XmlWriter writer, ServiceDocument document, string version)
174                 {
175                         Utility.WriteElementExtensions (document.ElementExtensions, writer, version);
176                 }
177
178                 protected static void WriteElementExtensions (XmlWriter writer, Workspace workspace, string version)
179                 {
180                         Utility.WriteElementExtensions (workspace.ElementExtensions, writer, version);
181                 }
182
183                 // instance members
184
185                 protected ServiceDocumentFormatter ()
186                         : this (new ServiceDocument ())
187                 {
188                 }
189
190                 protected ServiceDocumentFormatter (ServiceDocument documentToWrite)
191                 {
192                         SetDocument (documentToWrite);
193                 }
194
195                 public ServiceDocument Document { get; private set; }
196
197                 public abstract string Version { get; }
198
199
200                 public abstract bool CanRead (XmlReader reader);
201
202                 protected virtual ServiceDocument CreateDocumentInstance ()
203                 {
204                         return new ServiceDocument ();
205                 }
206
207                 public abstract void ReadFrom (XmlReader reader);
208
209                 protected virtual void SetDocument (ServiceDocument document)
210                 {
211                         if (document == null)
212                                 throw new ArgumentNullException ("document");
213                         Document = document;
214                 }
215
216                 public abstract void WriteTo (XmlWriter writer);
217         }
218 }