2 // ServiceDocumentFormatter.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2009 Novell, Inc. http://www.novell.com
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
29 using System.Collections.Generic;
31 using System.Runtime.Serialization;
32 using System.ServiceModel;
33 using System.ServiceModel.Channels;
36 namespace System.ServiceModel.Syndication
39 public abstract class ServiceDocumentFormatter
42 protected static SyndicationCategory CreateCategory (InlineCategoriesDocument inlineCategories)
44 throw new NotImplementedException ();
48 protected static ResourceCollectionInfo CreateCollection (Workspace workspace)
50 throw new NotImplementedException ();
54 protected static InlineCategoriesDocument CreateInlineCategories (ResourceCollectionInfo collection)
56 throw new NotImplementedException ();
60 protected static ReferencedCategoriesDocument CreateReferencedCategories (ResourceCollectionInfo collection)
62 throw new NotImplementedException ();
66 protected static Workspace CreateWorkspace (ServiceDocument document)
68 throw new NotImplementedException ();
72 protected static void LoadElementExtensions (XmlReader reader, CategoriesDocument categories, int maxExtensionSize)
74 throw new NotImplementedException ();
78 protected static void LoadElementExtensions (XmlReader reader,ResourceCollectionInfo collection, int maxExtensionSize)
80 throw new NotImplementedException ();
84 protected static void LoadElementExtensions (XmlReader reader, ServiceDocument document, int maxExtensionSize)
86 throw new NotImplementedException ();
90 protected static void LoadElementExtensions (XmlReader reader, Workspace workspace, int maxExtensionSize)
92 throw new NotImplementedException ();
96 protected static bool TryParseAttribute (string name, string ns, string value, CategoriesDocument categories, string version)
98 throw new NotImplementedException ();
102 protected static bool TryParseAttribute (string name, string ns, string value, ResourceCollectionInfo collection, string version)
104 throw new NotImplementedException ();
108 protected static bool TryParseAttribute (string name, string ns, string value, ServiceDocument document, string version)
110 throw new NotImplementedException ();
114 protected static bool TryParseAttribute (string name, string ns, string value, Workspace workspace, string version)
116 throw new NotImplementedException ();
120 protected static bool TryParseElement (XmlReader reader, CategoriesDocument categories, string version)
122 throw new NotImplementedException ();
126 protected static bool TryParseElement (XmlReader reader, ResourceCollectionInfo collection, string version)
128 throw new NotImplementedException ();
132 protected static bool TryParseElement (XmlReader reader, ServiceDocument document, string version)
134 throw new NotImplementedException ();
138 protected static bool TryParseElement (XmlReader reader, Workspace workspace, string version)
140 throw new NotImplementedException ();
143 protected static void WriteAttributeExtensions (XmlWriter writer, CategoriesDocument categories, string version)
145 Utility.WriteAttributeExtensions (categories.AttributeExtensions, writer, version);
148 protected static void WriteAttributeExtensions (XmlWriter writer, ResourceCollectionInfo collection, string version)
150 Utility.WriteAttributeExtensions (collection.AttributeExtensions, writer, version);
153 protected static void WriteAttributeExtensions (XmlWriter writer, ServiceDocument document, string version)
155 Utility.WriteAttributeExtensions (document.AttributeExtensions, writer, version);
158 protected static void WriteAttributeExtensions (XmlWriter writer, Workspace workspace, string version)
160 Utility.WriteAttributeExtensions (workspace.AttributeExtensions, writer, version);
163 protected static void WriteElementExtensions (XmlWriter writer, CategoriesDocument categories, string version)
165 Utility.WriteElementExtensions (categories.ElementExtensions, writer, version);
168 protected static void WriteElementExtensions (XmlWriter writer, ResourceCollectionInfo collection, string version)
170 Utility.WriteElementExtensions (collection.ElementExtensions, writer, version);
173 protected static void WriteElementExtensions (XmlWriter writer, ServiceDocument document, string version)
175 Utility.WriteElementExtensions (document.ElementExtensions, writer, version);
178 protected static void WriteElementExtensions (XmlWriter writer, Workspace workspace, string version)
180 Utility.WriteElementExtensions (workspace.ElementExtensions, writer, version);
185 protected ServiceDocumentFormatter ()
186 : this (new ServiceDocument ())
190 protected ServiceDocumentFormatter (ServiceDocument documentToWrite)
192 SetDocument (documentToWrite);
195 public ServiceDocument Document { get; private set; }
197 public abstract string Version { get; }
200 public abstract bool CanRead (XmlReader reader);
202 protected virtual ServiceDocument CreateDocumentInstance ()
204 return new ServiceDocument ();
207 public abstract void ReadFrom (XmlReader reader);
209 protected virtual void SetDocument (ServiceDocument document)
211 if (document == null)
212 throw new ArgumentNullException ("document");
216 public abstract void WriteTo (XmlWriter writer);