Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@ -0,0 +1,59 @@
//
// Atom10FeedFormatter_1.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace System.ServiceModel.Syndication
{
[XmlRoot ("feed", Namespace = "http://www.w3.org/2005/Atom")]
public class Atom10FeedFormatter<TSyndicationFeed> : Atom10FeedFormatter
where TSyndicationFeed : SyndicationFeed, new ()
{
public Atom10FeedFormatter ()
: base (typeof (TSyndicationFeed))
{
}
public Atom10FeedFormatter (TSyndicationFeed feedToWrite)
: base (typeof (TSyndicationFeed))
{
SetFeed (feedToWrite);
}
protected override SyndicationFeed CreateFeedInstance ()
{
return Activator.CreateInstance<TSyndicationFeed> ();
}
}
}

View File

@ -0,0 +1,59 @@
//
// Atom10ItemFormatter_1.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace System.ServiceModel.Syndication
{
[XmlRoot ("entry", Namespace = "http://www.w3.org/2005/Atom")]
public class Atom10ItemFormatter<TSyndicationItem> : Atom10ItemFormatter
where TSyndicationItem : SyndicationItem, new ()
{
public Atom10ItemFormatter ()
: base (typeof (TSyndicationItem))
{
}
public Atom10ItemFormatter (TSyndicationItem itemToWrite)
: base (typeof (TSyndicationItem))
{
SetItem (itemToWrite);
}
protected override SyndicationItem CreateItemInstance ()
{
return Activator.CreateInstance<TSyndicationItem> ();
}
}
}

View File

@ -0,0 +1,202 @@
//
// AtomPub10CategoriesDocumentFormatter.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2009 Novell, Inc. http://www.novell.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
namespace System.ServiceModel.Syndication
{
[XmlRoot ("categories", Namespace = Namespaces.AtomPP)]
public class AtomPub10CategoriesDocumentFormatter : CategoriesDocumentFormatter, IXmlSerializable
{
public AtomPub10CategoriesDocumentFormatter ()
: this (typeof (InlineCategoriesDocument), typeof (ReferencedCategoriesDocument))
{
}
public AtomPub10CategoriesDocumentFormatter (CategoriesDocument documentToWrite)
: base (documentToWrite)
{
}
public AtomPub10CategoriesDocumentFormatter (Type inlineDocumentType, Type referencedDocumentType)
{
if (inlineDocumentType == null)
throw new ArgumentNullException ("inlineDocumentType");
if (referencedDocumentType == null)
throw new ArgumentNullException ("referencedDocumentType");
inline_type = inlineDocumentType;
ref_type = referencedDocumentType;
}
Type inline_type, ref_type;
public override string Version {
get { return "http://www.w3.org/2007/app"; }
}
public override bool CanRead (XmlReader reader)
{
if (reader == null)
throw new ArgumentNullException ("reader");
reader.MoveToContent ();
return reader.LocalName != "categories" || reader.NamespaceURI != Version;
}
protected override InlineCategoriesDocument CreateInlineCategoriesDocument ()
{
return (InlineCategoriesDocument) Activator.CreateInstance (inline_type, new object [0]);
}
protected override ReferencedCategoriesDocument CreateReferencedCategoriesDocument ()
{
return (ReferencedCategoriesDocument) Activator.CreateInstance (ref_type, new object [0]);
}
public override void ReadFrom (XmlReader reader)
{
if (reader == null)
throw new ArgumentNullException ("reader");
reader.MoveToContent ();
bool isEmpty = reader.IsEmptyElement;
if (Document == null) {
var href = reader.GetAttribute ("href");
if (href != null) {
var doc = CreateReferencedCategoriesDocument ();
doc.Link = new Uri (href, UriKind.RelativeOrAbsolute);
SetDocument (doc);
} else {
var doc = CreateInlineCategoriesDocument ();
doc.Scheme = reader.GetAttribute ("scheme");
if (reader.GetAttribute ("fixed") == "yes")
doc.IsFixed = true;
SetDocument (doc);
}
}
var inline = Document as InlineCategoriesDocument;
// var referenced = Document as ReferencedCategoriesDocument;
reader.ReadStartElement ("categories", Version);
if (isEmpty)
return;
for (reader.MoveToContent ();
reader.NodeType != XmlNodeType.EndElement;
reader.MoveToContent ()) {
if (inline != null && reader.LocalName == "category" && reader.NamespaceURI == Namespaces.Atom10)
ReadInlineCategoriesContent (inline, reader);
// FIXME: else read element as an extension
else
reader.Skip ();
}
reader.ReadEndElement (); // </app:categories>
}
void ReadInlineCategoriesContent (InlineCategoriesDocument doc, XmlReader reader)
{
var cat = new SyndicationCategory ();
atom10_formatter.ReadCategory (reader, cat);
doc.Categories.Add (cat);
}
public override void WriteTo (XmlWriter writer)
{
if (writer == null)
throw new ArgumentNullException ("writer");
writer.WriteStartElement ("app", "categories", Version);
if (writer.LookupPrefix (Namespaces.Atom10) != "a10")
writer.WriteAttributeString ("xmlns", "a10", Namespaces.Xmlns, Namespaces.Atom10);
// xml:lang, xml:base, term, scheme, label
if (Document.Language != null)
writer.WriteAttributeString ("xml", "lang", Namespaces.Xml, Document.Language);
if (Document.BaseUri != null)
writer.WriteAttributeString ("xml", "base", Namespaces.Xml, Document.BaseUri.ToString ());
InlineCategoriesDocument inline = Document as InlineCategoriesDocument;
ReferencedCategoriesDocument referenced = Document as ReferencedCategoriesDocument;
// ... no term ?
if (inline != null) {
if (inline.IsFixed)
writer.WriteAttributeString ("fixed", "yes");
if (inline.Scheme != null)
writer.WriteAttributeString ("scheme", inline.Scheme);
} else if (referenced != null) {
if (referenced.Link != null)
writer.WriteAttributeString ("href", referenced.Link.ToString ());
}
Document.WriteAttributeExtensions (writer, Version);
Document.WriteElementExtensions (writer, Version);
if (inline != null)
WriteInlineCategoriesContent (inline, writer);
// no (non-extension) contents for out-of-line category
writer.WriteEndElement ();
}
Atom10FeedFormatter atom10_formatter = new Atom10FeedFormatter ();
void WriteInlineCategoriesContent (InlineCategoriesDocument doc, XmlWriter writer)
{
foreach (var cat in doc.Categories)
atom10_formatter.WriteCategory (cat, writer);
}
XmlSchema IXmlSerializable.GetSchema ()
{
return null;
}
void IXmlSerializable.ReadXml (XmlReader reader)
{
ReadFrom (reader);
}
void IXmlSerializable.WriteXml (XmlWriter writer)
{
WriteTo (writer);
}
}
}

View File

@ -0,0 +1,173 @@
//
// AtomPub10ServiceDocumentFormatter.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2009 Novell, Inc. http://www.novell.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
namespace System.ServiceModel.Syndication
{
class Namespaces
{
public const string Xml = "http://www.w3.org/XML/1998/namespace";
public const string Xmlns = "http://www.w3.org/2000/xmlns/";
public const string AtomPP = "http://www.w3.org/2007/app";
public const string Atom10 = "http://www.w3.org/2005/Atom";
}
[XmlRoot ("service", Namespace = Namespaces.AtomPP)]
public class AtomPub10ServiceDocumentFormatter : ServiceDocumentFormatter, IXmlSerializable
{
public AtomPub10ServiceDocumentFormatter ()
{
}
public AtomPub10ServiceDocumentFormatter (ServiceDocument documentToWrite)
: base (documentToWrite)
{
}
public AtomPub10ServiceDocumentFormatter (Type documentTypeToCreate)
{
doc_type = documentTypeToCreate;
}
Type doc_type;
public override string Version {
get { return Namespaces.AtomPP; }
}
public override bool CanRead (XmlReader reader)
{
if (reader == null)
throw new ArgumentNullException ("reader");
reader.MoveToContent ();
return reader.LocalName == "service" && reader.NamespaceURI == Version;
}
protected override ServiceDocument CreateDocumentInstance ()
{
var doc = doc_type != null ? (ServiceDocument) Activator.CreateInstance (doc_type, new object [0]) : base.CreateDocumentInstance ();
doc.InternalFormatter = this;
return doc;
}
public override void ReadFrom (XmlReader reader)
{
if (!Document.TryParseElement (reader, Version))
throw new XmlException (String.Format ("Unexpected element '{0}' in namespace '{1}'", reader.LocalName, reader.NamespaceURI));
}
public override void WriteTo (XmlWriter writer)
{
if (writer == null)
throw new ArgumentNullException ("writer");
writer.WriteStartElement ("app", "service", Version);
WriteContentTo (writer);
writer.WriteEndElement ();
}
void WriteContentTo (XmlWriter writer)
{
if (writer.LookupPrefix (Namespaces.Atom10) == null)
writer.WriteAttributeString ("xmlns", "a10", Namespaces.Xmlns, Namespaces.Atom10);
if (writer.LookupPrefix (Version) == null)
writer.WriteAttributeString ("xmlns", "app", Namespaces.Xmlns, Version);
// xml:lang, xml:base, workspace*
if (Document.Language != null)
writer.WriteAttributeString ("xml", "lang", Namespaces.Xml, Document.Language);
if (Document.BaseUri != null)
writer.WriteAttributeString ("xml", "base", Namespaces.Xml, Document.BaseUri.ToString ());
Document.WriteAttributeExtensions (writer, Version);
Document.WriteElementExtensions (writer, Version);
foreach (var ws in Document.Workspaces) {
writer.WriteStartElement ("app", "workspace", Version);
// xml:base, title, collection*
if (ws.BaseUri != null)
writer.WriteAttributeString ("xml", "base", Namespaces.Xml, ws.BaseUri.ToString ());
ws.WriteAttributeExtensions (writer, Version);
ws.WriteElementExtensions (writer, Version);
if (ws.Title != null)
ws.Title.WriteTo (writer, "title", Namespaces.Atom10);
foreach (var rc in ws.Collections) {
writer.WriteStartElement ("app", "collection", Version);
// accept*, xml:base, category, @href, title
if (rc.BaseUri != null)
writer.WriteAttributeString ("xml", "base", Namespaces.Xml, rc.BaseUri.ToString ());
if (rc.Link != null)
writer.WriteAttributeString ("href", rc.Link.ToString ());
rc.WriteAttributeExtensions (writer, Version);
if (rc.Title != null)
rc.Title.WriteTo (writer, "title", Namespaces.Atom10);
foreach (var s in rc.Accepts) {
writer.WriteStartElement ("app", "accept", Version);
writer.WriteString (s);
writer.WriteEndElement ();
}
foreach (var cat in rc.Categories)
cat.Save (writer);
writer.WriteEndElement ();
}
writer.WriteEndElement ();
}
}
XmlSchema IXmlSerializable.GetSchema ()
{
return null;
}
void IXmlSerializable.ReadXml (XmlReader reader)
{
ReadFrom (reader);
}
void IXmlSerializable.WriteXml (XmlWriter writer)
{
WriteContentTo (writer);
}
}
}

View File

@ -0,0 +1,55 @@
//
// AtomPub10ServiceDocumentFormatter_1.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2009 Novell, Inc. http://www.novell.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml.Serialization;
namespace System.ServiceModel.Syndication
{
[XmlRoot ("service", Namespace = Namespaces.AtomPP)]
public class AtomPub10ServiceDocumentFormatter<TServiceDocument> : AtomPub10ServiceDocumentFormatter
where TServiceDocument : ServiceDocument, new()
{
public AtomPub10ServiceDocumentFormatter ()
{
}
public AtomPub10ServiceDocumentFormatter (TServiceDocument documentToWrite)
: base (documentToWrite)
{
}
protected override ServiceDocument CreateDocumentInstance ()
{
return new TServiceDocument ();
}
}
}

View File

@ -0,0 +1,144 @@
//
// CategoriesDocument.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2009 Novell, Inc. http://www.novell.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml;
namespace System.ServiceModel.Syndication
{
public abstract class CategoriesDocument
{
public static InlineCategoriesDocument Create (Collection<SyndicationCategory> categories)
{
return new InlineCategoriesDocument (categories);
}
public static ReferencedCategoriesDocument Create (Uri linkToCategoriesDocument)
{
return new ReferencedCategoriesDocument (linkToCategoriesDocument);
}
public static InlineCategoriesDocument Create (Collection<SyndicationCategory> categories, bool isFixed, string scheme)
{
return new InlineCategoriesDocument (categories, isFixed, scheme);
}
public static CategoriesDocument Load (XmlReader reader)
{
if (reader == null)
throw new ArgumentNullException ("reader");
var f = new AtomPub10CategoriesDocumentFormatter ();
reader.MoveToContent ();
CategoriesDocument doc;
if (reader.GetAttribute ("href") == null)
doc = new InlineCategoriesDocument ();
else
doc = new ReferencedCategoriesDocument ();
doc.GetFormatter ().ReadFrom (reader);
return doc;
}
internal CategoriesDocument ()
{
}
CategoriesDocumentFormatter formatter;
SyndicationExtensions extensions = new SyndicationExtensions ();
public Dictionary<XmlQualifiedName, string> AttributeExtensions {
get { return extensions.Attributes; }
}
public Uri BaseUri { get; set; }
public SyndicationElementExtensionCollection ElementExtensions {
get { return extensions.Elements; }
}
public string Language { get; set; }
public CategoriesDocumentFormatter GetFormatter ()
{
if (formatter == null)
formatter = new AtomPub10CategoriesDocumentFormatter (this);
return formatter;
}
public void Save (XmlWriter writer)
{
GetFormatter ().WriteTo (writer);
}
protected internal virtual bool TryParseAttribute (string name, string ns, string value, string version)
{
var inline = this as InlineCategoriesDocument;
if (name == "lang" && ns == Namespaces.Xml)
Language = value;
else if (name == "base" && ns == Namespaces.Xml)
BaseUri = new Uri (value, UriKind.RelativeOrAbsolute);
else if (name == "href" && ns == String.Empty && this is ReferencedCategoriesDocument)
((ReferencedCategoriesDocument) this).Link = new Uri (value, UriKind.RelativeOrAbsolute);
else if (name == "fixed" && ns == String.Empty && inline != null && value == "true")
inline.IsFixed = true;
else if (name == "scheme" && ns == String.Empty && inline != null)
inline.Scheme = value;
else
return false;
return true;
}
protected internal virtual bool TryParseElement (XmlReader reader, string version)
{
if (reader == null)
throw new ArgumentNullException ("reader");
var f = GetFormatter ();
if (!f.CanRead (reader))
return false;
f.ReadFrom (reader);
return true;
}
protected internal virtual void WriteAttributeExtensions (XmlWriter writer, string version)
{
extensions.WriteAttributeExtensions (writer, version);
}
protected internal virtual void WriteElementExtensions (XmlWriter writer, string version)
{
extensions.WriteElementExtensions (writer, version);
}
}
}

View File

@ -0,0 +1,79 @@
//
// CategoriesDocumentFormatter.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2009 Novell, Inc. http://www.novell.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml;
namespace System.ServiceModel.Syndication
{
[DataContract]
public abstract class CategoriesDocumentFormatter
{
protected CategoriesDocumentFormatter ()
{
}
protected CategoriesDocumentFormatter (CategoriesDocument documentToWrite)
{
SetDocument (documentToWrite);
}
public CategoriesDocument Document { get; private set; }
public abstract string Version { get; }
public abstract bool CanRead (XmlReader reader);
protected virtual InlineCategoriesDocument CreateInlineCategoriesDocument ()
{
return new InlineCategoriesDocument ();
}
protected virtual ReferencedCategoriesDocument CreateReferencedCategoriesDocument ()
{
return new ReferencedCategoriesDocument ();
}
public abstract void ReadFrom (XmlReader reader);
protected virtual void SetDocument (CategoriesDocument document)
{
if (document == null)
throw new ArgumentNullException ("document");
Document = document;
}
public abstract void WriteTo (XmlWriter writer);
}
}

View File

@ -0,0 +1,282 @@
2010-06-18 Atsushi Enomoto <atsushi@ximian.com>
* Rss20ItemFormatter.cs : enabled DateTimeOffset parsing.
Fixed bug #615332, patch by Carlos Martin.
2010-06-16 Atsushi Enomoto <atsushi@ximian.com>
* Atom10ItemFormatter.cs : Fix reading of "source" element to not
expect feed element (ReadFrom() expects it). Fixed bug #614596.
2010-06-07 Carlos Martin Nieto <carlos@cmartin.tk>
* Rss20ItemFormatter.cs: Don't assume guids are permalinks
2009-12-01 Atsushi Enomoto <atsushi@ximian.com>
* Atom10ItemFormatter.cs, Atom10FeedFormatter.cs :
write extensions. Patch by Tom Philpot.
2009-10-16 Atsushi Enomoto <atsushi@ximian.com>
* Rss20FeedFormatter.cs, Rss20ItemFormatter.cs : handle other text
nodes than text (cdata, whitespaces etc.) and make sure to proceed
the reader when they are skipped. Fixed bug #546965 and #546959.
2009-10-07 Atsushi Enomoto <atsushi@ximian.com>
* SyndicationVersions.cs :
Handle atom feed as well. Patch by David Mitchell.
2009-10-07 Atsushi Enomoto <atsushi@ximian.com>
* SyndicationElementExtension.cs : give OuterName and OuterNamespace
for extensions with .ctor(XmlReader).
2009-10-05 Atsushi Enomoto <atsushi@ximian.com>
* Atom10FeedFormatter.cs : do not use Atom10ItemFormatter(item)
at ReadItem(). It is only for writing. Patch by David Mitchell.
2009-10-05 Atsushi Enomoto <atsushi@ximian.com>
* Atom10ItemFormatter.cs : enable XmlConvert.ToDateTimeOffset(),
patch by David Mitchell.
2009-09-15 Atsushi Enomoto <atsushi@ximian.com>
* SyndicationElementExtension.cs : make it ready for 2.1 build.
2009-09-07 Atsushi Enomoto <atsushi@ximian.com>
* Rss20FeedFormatter.cs, CategoriesDocument.cs,
AtomPub10ServiceDocumentFormatter_1.cs,
AtomPub10CategoriesDocumentFormatter.cs,
AtomPub10ServiceDocumentFormatter.cs : a couple of corcompare fixes.
2009-04-15 Atsushi Enomoto <atsushi@ximian.com>
* ServiceDocument.cs : remove Utility class. It is not precise
implementation to write extensions.
* ServiceDocumentFormatter.cs : virtual extension writer methods
should call possibly overriden Write[Element/Attribute]Extensions()
in possibly derived document item classes.
Implemented LoadElementExtensions().
* AtomPub10CategoriesDocumentFormatter.cs,
AtomPub10ServiceDocumentFormatter.cs : Implemented GetSchema().
2009-04-06 Atsushi Enomoto <atsushi@ximian.com>
* ServiceDocumentFormatter.cs
Workspace.cs
Atom10FeedFormatter.cs
AtomPub10ServiceDocumentFormatter.cs
ResourceCollectionInfo.cs
CategoriesDocument.cs
ServiceDocument.cs : implemented most of reader parts.
2009-04-06 Atsushi Enomoto <atsushi@ximian.com>
* Workspace.cs, ResourceCollectionInfo.cs,
CategoriesDocument.cs, ServiceDocument.cs : use common internal
SyndicationExtension class for extensions.
2009-04-06 Atsushi Enomoto <atsushi@ximian.com>
* AtomPub10CategoriesDocumentFormatter.cs, Atom10FeedFormatter.cs,
CategoriesDocument.cs : ongoing implementation (handle categories).
2009-04-03 Atsushi Enomoto <atsushi@ximian.com>
* ServiceDocumentFormatter.cs
Workspace.cs
AtomPub10ServiceDocumentFormatter.cs
ResourceCollectionInfo.cs
CategoriesDocument.cs
ServiceDocument.cs : ongoing implementation.
2009-04-03 Atsushi Enomoto <atsushi@ximian.com>
* ServiceDocumentFormatter.cs
InlineCategoriesDocument.cs
AtomPub10ServiceDocumentFormatter_1.cs
Workspace.cs
AtomPub10CategoriesDocumentFormatter.cs
ReferencedCategoriesDocument.cs
CategoriesDocumentFormatter.cs
AtomPub10ServiceDocumentFormatter.cs
ResourceCollectionInfo.cs
CategoriesDocument.cs
ServiceDocument.cs : stubs (new in 3.5 SP1).
2008-04-10 Eyal Alaluf <eyala@mainsoft.com>
* SyndicationElementExtension.cs: XmlObjectSerializer.ReadObject now
verifies by default. Disabled explicitly the verification in GetObject.
2007-12-18 Atsushi Enomoto <atsushi@ximian.com>
* SyndicationElementExtensionCollection.cs, Atom10FeedFormatter.cs,
Atom10ItemFormatter.cs, Rss20FeedFormatter.cs : warning cleanup.
* SyndicationItem.cs : implemented TryParseContent().
* Atom10ItemFormatter.cs : read Content.
* Rss20ItemFormatter.cs : Handle Atom 1.0 extension elements.
Fixed ReadSourceFeed() that should read <source> in its own way.
2007-12-18 Atsushi Enomoto <atsushi@ximian.com>
* Atom10ItemFormatter.cs : changes in extension attribute handling:
TryParseAttribute() should be called regardless of
PreserveExtensionAttributes.
* SyndicationFeedFormatter.cs, SyndicationItemFormatter.cs :
implemented ToString().
* Rss20FeedFormatter.cs : strictly require <channel> under <rss>.
2007-12-18 Atsushi Enomoto <atsushi@ximian.com>
* Atom10ItemFormatter.cs : implemented read methods and GetSchema().
2007-12-18 Atsushi Enomoto <atsushi@ximian.com>
* SyndicationFeedFormatter.cs : implemented LoadElementExtensions().
* Rss20FeedFormatter.cs : implemented read methods and GetSchema().
PreserveElementExtensions and PreserveAttributeExtensions are
true by default.
* Rss20ItemFormatter.cs : filter xmlns attributes out.
2007-12-18 Atsushi Enomoto <atsushi@ximian.com>
* SyndicationElementExtensionCollection.cs :
every Add() caused infinite loop.
* SyndicationFeed.cs, SyndicationItem.cs : Implemented Load() and [*1]
* SyndicationLink.cs : int set_Length() argument check was wrong. [*1]
* SyndicationCategory.cs, SyndicationPerson.cs : [*1]
* SyndicationItemFormatter.cs : Implemented LoadElementExtensions().
* SyndicationVersions.cs : added SyndicationItem.Load<T>() and
SyndicationFeed<T>() implementation.
* Atom10ItemFormatter.cs : [*2]
* Rss20ItemFormatter.cs : implemented read methods. [*2]
[*1] Implemented TryParseElement and TryParseAttribute.
[*2] PreserveElementExtensions and PreserveAttributeExtensions are
true by default.
2007-12-17 Atsushi Enomoto <atsushi@ximian.com>
* Atom10FeedFormatter_1.cs, Atom10ItemFormatter_1.cs,
Rss20FeedFormatter_1.cs, Rss20ItemFormatter_1.cs : implemented.
* Atom10FeedFormatter.cs, Atom10ItemFormatter.cs,
Rss20FeedFormatter.cs, Rss20ItemFormatter.cs :
implemented instance creation. Some parameter renaming.
2007-12-17 Atsushi Enomoto <atsushi@ximian.com>
* Rss20FeedFormatter.cs : s:/item/feed/ in the error message.
* Atom10FeedFormatter.cs : implemented WriteTo() and WriteXml().
2007-12-17 Atsushi Enomoto <atsushi@ximian.com>
* Atom10ItemFormatter.cs : some more notes on its spec violation.
2007-12-17 Atsushi Enomoto <atsushi@ximian.com>
* Rss20ItemFormatter.cs : enclose SourceFeed with <source>.
* Atom10ItemFormatter.cs : implemented WriteTo() and WriteXml().
2007-12-15 Atsushi Enomoto <atsushi@ximian.com>
* Rss20ItemFormatter.cs : some parameter renaming.
* SyndicationFeedFormatter.cs, Rss20FeedFormatter.cs : implemented,
based on item formatter.
* SyndicationItemFormatter.cs : implemented syndication element
creation methods. Added null argument checks.
2007-12-15 Atsushi Enomoto <atsushi@ximian.com>
* Rss20ItemFormatter.cs : write remaining properties in item.
* UrlSyndicationContent.cs : implemented.
* XmlSyndicationContent.cs, SyndicationContent.cs,
SyndicationElementExtensionCollection.cs : mostly implemented; now
I mostly found that those unimplemented stuff were bound to
SyndicationElementExtension constructors.
2007-12-15 Atsushi Enomoto <atsushi@ximian.com>
* SyndicationFeed.cs : do not try to set null items in .ctor() (null
items are allowed in .ctor, while not allowed in set_Items()).
Remove extra NotImplementedException.
Implemented WriteAttributeExtensions and WriteElementExtensions.
* SyndicationElementExtension.cs : implemented.
* SyndicationExtensions.cs,
SyndicationItem.cs, SyndicationLink.cs, SyndicationCategory.cs,
SyndicationPerson.cs : Implemented WriteAttributeExtensions() and
WriteElementExtensions() in each syndication element to call
corresponding method in SyndicationExtensions.
* SyndicationItemFormatter.cs :
implemented Write[Element/Attribute]Extensions() and
TryParse[Element/Attribute]().
* Rss20ItemFormatter.cs : write extensions on writing to xml.
Null check in Contributors on writing to xml.
2007-12-11 Atsushi Enomoto <atsushi@ximian.com>
* Rss20ItemFormatter.cs, SyndicationContent.cs,
TextSyndicationContent.cs : flush some more implementation.
2007-12-10 Atsushi Enomoto <atsushi@ximian.com>
* Atom10ItemFormatter.cs, Rss20ItemFormatter.cs,
SyndicationCategory.cs, SyndicationContent.cs, SyndicationFeed.cs,
SyndicationItem.cs, SyndicationItemFormatter.cs,
SyndicationPerson.cs : a bunch of implementation.
2007-12-10 Atsushi Enomoto <atsushi@ximian.com>
* SyndicationElementExtensionCollection.cs : added copy .ctor().
* SyndicationLink.cs : implemented everything but read/write part.
2007-12-10 Atsushi Enomoto <atsushi@ximian.com>
* Atom10FeedFormatter.cs Atom10FeedFormatter_1.cs
Atom10ItemFormatter.cs Atom10ItemFormatter_1.cs
Rss20FeedFormatter.cs Rss20FeedFormatter_1.cs
Rss20ItemFormatter.cs Rss20ItemFormatter_1.cs
SyndicationCategory.cs SyndicationElementExtension.cs
SyndicationElementExtensionCollection.cs SyndicationFeed.cs
SyndicationItem.cs SyndicationLink.cs SyndicationPerson.cs:
finished stubs.
* ISyndicationElement.cs : internal interface, introduced to reduce
corcompare obstacles.
2007-12-07 Atsushi Enomoto <atsushi@ximian.com>
* Atom10ItemFormatter.cs, Atom10ItemFormatter_1.cs,
Rss20ItemFormatter.cs, Rss20ItemFormatter_1.cs,
SyndicationItemFormatter.cs : more new stubs.
* SyndicationFeedFormatter.cs, SyndicationItem.cs,
SyndicationLink.cs, SyndicationPerson.cs : more stub fixes.
2007-12-07 Atsushi Enomoto <atsushi@ximian.com>
* TextSyndicationContent.cs, XmlSyndicationContent.cs,
UrlSyndicationContent.cs : new stubs.
* SyndicationContent.cs, TextSyndicationContentKind.cs,
SyndicationFeedFormatter.cs, SyndicationFeed.cs :
ongoing stub fixes.
2007-12-07 Atsushi Enomoto <atsushi@ximian.com>
* Ato10FeedFormatter.cs Atom10FeedFormatter.cs :
oops, wrong file name. renamed former to latter.
2007-12-05 Atsushi Enomoto <atsushi@ximian.com>
* Ato10FeedFormatter.cs Atom10FeedFormatter_1.cs
Rss20FeedFormatter.cs Rss20FeedFormatter_1.cs
SyndicationCategory.cs SyndicationContent.cs
SyndicationElementExtension.cs
SyndicationElementExtensionCollection.cs
SyndicationFeed.cs SyndicationFeedFormatter.cs
SyndicationItem.cs SyndicationLink.cs SyndicationPerson.cs
SyndicationVersions.cs TextSyndicationContentKind.cs :
new stubs.

View File

@ -0,0 +1,42 @@
//
// Atom10FeedFormatter.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Xml;
namespace System.ServiceModel.Syndication
{
// For now it makes few points; just to hide some corcompare obstacles
// for "Final Virtual" members in syndication elements.
interface ISyndicationElement
{
Dictionary<XmlQualifiedName, string> AttributeExtensions { get; }
SyndicationElementExtensionCollection ElementExtensions { get; }
}
}

View File

@ -0,0 +1,70 @@
//
// InlineCategoriesDocument.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2009 Novell, Inc. http://www.novell.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml;
namespace System.ServiceModel.Syndication
{
public class InlineCategoriesDocument : CategoriesDocument
{
public InlineCategoriesDocument ()
{
Categories = new Collection<SyndicationCategory> ();
}
public InlineCategoriesDocument (IEnumerable<SyndicationCategory> categories)
: this ()
{
foreach (var i in categories)
Categories.Add (i);
}
public InlineCategoriesDocument (IEnumerable<SyndicationCategory> categories, bool isFixed, string scheme)
: this (categories)
{
IsFixed = isFixed;
Scheme = scheme;
}
protected internal virtual SyndicationCategory CreateCategory ()
{
return new SyndicationCategory ();
}
public Collection<SyndicationCategory> Categories { get; private set; }
public bool IsFixed { get; set; }
public string Scheme { get; set; }
}
}

View File

@ -0,0 +1,49 @@
//
// ReferencedCategoriesDocument.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2009 Novell, Inc. http://www.novell.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Channels;
namespace System.ServiceModel.Syndication
{
public class ReferencedCategoriesDocument : CategoriesDocument
{
public ReferencedCategoriesDocument ()
{
}
public ReferencedCategoriesDocument (Uri link)
{
Link = link;
}
public Uri Link { get; set; }
}
}

View File

@ -0,0 +1,160 @@
//
// ResourceCollectionInfo.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2009 Novell, Inc. http://www.novell.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml;
namespace System.ServiceModel.Syndication
{
public class ResourceCollectionInfo
{
public ResourceCollectionInfo ()
{
Accepts = new Collection<string> ();
Categories = new Collection<CategoriesDocument> ();
}
public ResourceCollectionInfo (TextSyndicationContent title, Uri link)
: this ()
{
Title = title;
Link = link;
}
public ResourceCollectionInfo (string title, Uri link)
: this (new TextSyndicationContent (title), link)
{
}
public ResourceCollectionInfo (TextSyndicationContent title, Uri link, IEnumerable<CategoriesDocument> categories, bool allowsNewEntries)
: this (title, link)
{
if (categories == null)
throw new ArgumentNullException ("categories");
foreach (var c in categories)
Categories.Add (c);
allow_new_entries = allowsNewEntries;
}
public ResourceCollectionInfo (TextSyndicationContent title, Uri link, IEnumerable<CategoriesDocument> categories, IEnumerable<string> accepts)
: this (title, link, categories, true)
{
if (accepts == null)
throw new ArgumentNullException ("accepts");
foreach (var a in accepts)
Accepts.Add (a);
}
bool allow_new_entries;
SyndicationExtensions extensions = new SyndicationExtensions ();
public Collection<string> Accepts { get; private set; }
public Dictionary<XmlQualifiedName, string> AttributeExtensions {
get { return extensions.Attributes; }
}
public Uri BaseUri { get; set; }
public Collection<CategoriesDocument> Categories { get; private set; }
public SyndicationElementExtensionCollection ElementExtensions {
get { return extensions.Elements; }
}
public Uri Link { get; set; }
public TextSyndicationContent Title { get; set; }
protected internal virtual InlineCategoriesDocument CreateInlineCategoriesDocument ()
{
return new InlineCategoriesDocument ();
}
protected internal virtual ReferencedCategoriesDocument CreateReferencedCategoriesDocument ()
{
return new ReferencedCategoriesDocument ();
}
protected internal virtual bool TryParseAttribute (string name, string ns, string value, string version)
{
if (name == "base" && ns == Namespaces.Xml)
BaseUri = new Uri (value, UriKind.RelativeOrAbsolute);
else if (name == "href" && ns == String.Empty)
Link = new Uri (value, UriKind.RelativeOrAbsolute);
else
return false;
return true;
}
protected internal virtual bool TryParseElement (XmlReader reader, string version)
{
if (reader == null)
throw new ArgumentNullException ("reader");
reader.MoveToContent ();
if (reader.LocalName != "collection" || reader.NamespaceURI != version)
return false;
for (int i = 0; i < reader.AttributeCount; i++) {
reader.MoveToAttribute (i);
if (!TryParseAttribute (reader.LocalName, reader.NamespaceURI, reader.Value, version))
AttributeExtensions.Add (new XmlQualifiedName (reader.LocalName, reader.NamespaceURI), reader.Value);
}
reader.MoveToElement ();
if (!reader.IsEmptyElement) {
reader.Read ();
for (reader.MoveToContent (); reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ()) {
if (reader.LocalName == "title" && reader.NamespaceURI == Namespaces.Atom10)
Title = Atom10FeedFormatter.ReadTextSyndicationContent (reader);
else
ElementExtensions.Add (new SyndicationElementExtension (reader));
}
}
reader.Read ();
return true;
}
protected internal virtual void WriteAttributeExtensions (XmlWriter writer, string version)
{
extensions.WriteAttributeExtensions (writer, version);
}
protected internal virtual void WriteElementExtensions (XmlWriter writer, string version)
{
extensions.WriteElementExtensions (writer, version);
}
}
}

View File

@ -0,0 +1,66 @@
//
// Rss20FeedFormatter_1.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace System.ServiceModel.Syndication
{
[XmlRoot ("rss", Namespace = "")]
public class Rss20FeedFormatter<TSyndicationFeed> : Rss20FeedFormatter
where TSyndicationFeed : SyndicationFeed, new ()
{
public Rss20FeedFormatter ()
: base (typeof (TSyndicationFeed))
{
}
public Rss20FeedFormatter (TSyndicationFeed feedToWrite)
: base (typeof (TSyndicationFeed))
{
SetFeed (feedToWrite);
}
public Rss20FeedFormatter (TSyndicationFeed feedToWrite, bool serializeExtensionsAsAtom)
: base (typeof (TSyndicationFeed))
{
SetFeed (feedToWrite);
SerializeExtensionsAsAtom = serializeExtensionsAsAtom;
}
protected override SyndicationFeed CreateFeedInstance ()
{
return Activator.CreateInstance<TSyndicationFeed> ();
}
}
}

View File

@ -0,0 +1,66 @@
//
// Rss20ItemFormatter_1.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace System.ServiceModel.Syndication
{
[XmlRoot ("item", Namespace = "")]
public class Rss20ItemFormatter<TSyndicationItem> : Rss20ItemFormatter
where TSyndicationItem : SyndicationItem, new ()
{
public Rss20ItemFormatter ()
: base (typeof (TSyndicationItem))
{
}
public Rss20ItemFormatter (TSyndicationItem itemToWrite)
: base (typeof (TSyndicationItem))
{
SetItem (itemToWrite);
}
public Rss20ItemFormatter (TSyndicationItem itemToWrite, bool serializeExtensionsAsAtom)
: base (typeof (TSyndicationItem))
{
SetItem (itemToWrite);
SerializeExtensionsAsAtom = serializeExtensionsAsAtom;
}
protected override SyndicationItem CreateItemInstance ()
{
return Activator.CreateInstance<TSyndicationItem> ();
}
}
}

View File

@ -0,0 +1,174 @@
//
// ServiceDocument.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2009 Novell, Inc. http://www.novell.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml;
namespace System.ServiceModel.Syndication
{
public class ServiceDocument
{
public static TServiceDocument Load<TServiceDocument> (XmlReader reader)
where TServiceDocument : ServiceDocument, new()
{
var doc = new TServiceDocument ();
new AtomPub10ServiceDocumentFormatter<TServiceDocument> (doc).ReadFrom (reader);
return doc;
}
public static ServiceDocument Load (XmlReader reader)
{
return Load<ServiceDocument> (reader);
}
public ServiceDocument ()
{
Workspaces = new Collection<Workspace> ();
}
public ServiceDocument (IEnumerable<Workspace> workspaces)
: this ()
{
if (workspaces != null)
foreach (var w in workspaces)
Workspaces.Add (w);
}
ServiceDocumentFormatter formatter;
SyndicationExtensions extensions = new SyndicationExtensions ();
internal ServiceDocumentFormatter InternalFormatter {
set { formatter = value; }
}
public Dictionary<XmlQualifiedName, string> AttributeExtensions {
get { return extensions.Attributes; }
}
public Uri BaseUri { get; set; }
public SyndicationElementExtensionCollection ElementExtensions {
get { return extensions.Elements; }
}
public string Language { get; set; }
public Collection<Workspace> Workspaces { get; private set; }
protected internal virtual Workspace CreateWorkspace ()
{
return new Workspace ();
}
public ServiceDocumentFormatter GetFormatter ()
{
if (formatter == null)
formatter = new AtomPub10ServiceDocumentFormatter (this);
return formatter;
}
public void Save (XmlWriter writer)
{
GetFormatter ().WriteTo (writer);
}
protected internal virtual bool TryParseAttribute (string name, string ns, string value, string version)
{
if (version != "http://www.w3.org/2007/app")
return false;
switch (ns) {
case "http://www.w3.org/XML/1998/namespace":
switch (name) {
case "base":
BaseUri = new Uri (value, UriKind.RelativeOrAbsolute);
return true;
case "lang":
Language = value;
return true;
}
return false;
}
return false;
}
protected internal virtual bool TryParseElement (XmlReader reader, string version)
{
if (reader == null)
throw new ArgumentNullException ("reader");
reader.MoveToContent ();
if (reader.LocalName != "service" || reader.NamespaceURI != version)
return false;
for (int i = 0; i < reader.AttributeCount; i++) {
reader.MoveToAttribute (i);
if (!TryParseAttribute (reader.LocalName, reader.NamespaceURI, reader.Value, version))
AttributeExtensions.Add (new XmlQualifiedName (reader.LocalName, reader.NamespaceURI), reader.Value);
}
reader.MoveToElement ();
if (reader.IsEmptyElement)
throw new XmlException ("AtomPP service element requires at least one workspace element");
reader.ReadStartElement ();
for (reader.MoveToContent (); reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ()) {
if (reader.LocalName == "workspace" && reader.NamespaceURI == version) {
var ws = CreateWorkspace ();
if (ws.TryParseElement (reader, version)) {
Workspaces.Add (ws);
continue;
}
}
ElementExtensions.Add (new SyndicationElementExtension (reader));
}
reader.ReadEndElement ();
return true;
}
protected internal virtual void WriteAttributeExtensions (XmlWriter writer, string version)
{
extensions.WriteAttributeExtensions (writer, version);
}
protected internal virtual void WriteElementExtensions (XmlWriter writer, string version)
{
extensions.WriteElementExtensions (writer, version);
}
}
}

View File

@ -0,0 +1,205 @@
//
// ServiceDocumentFormatter.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2009 Novell, Inc. http://www.novell.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml;
namespace System.ServiceModel.Syndication
{
[DataContract]
public abstract class ServiceDocumentFormatter
{
protected static SyndicationCategory CreateCategory (InlineCategoriesDocument inlineCategories)
{
return inlineCategories.CreateCategory ();
}
protected static ResourceCollectionInfo CreateCollection (Workspace workspace)
{
return workspace.CreateResourceCollection ();
}
protected static InlineCategoriesDocument CreateInlineCategories (ResourceCollectionInfo collection)
{
return collection.CreateInlineCategoriesDocument ();
}
protected static ReferencedCategoriesDocument CreateReferencedCategories (ResourceCollectionInfo collection)
{
return collection.CreateReferencedCategoriesDocument ();
}
protected static Workspace CreateWorkspace (ServiceDocument document)
{
return document.CreateWorkspace ();
}
[MonoTODO ("Use maxExtensionSize somewhere")]
protected static void LoadElementExtensions (XmlReader reader, CategoriesDocument categories, int maxExtensionSize)
{
categories.ElementExtensions.Add (reader);
}
[MonoTODO ("Use maxExtensionSize somewhere")]
protected static void LoadElementExtensions (XmlReader reader,ResourceCollectionInfo collection, int maxExtensionSize)
{
collection.ElementExtensions.Add (reader);
}
[MonoTODO ("Use maxExtensionSize somewhere")]
protected static void LoadElementExtensions (XmlReader reader, ServiceDocument document, int maxExtensionSize)
{
document.ElementExtensions.Add (reader);
}
[MonoTODO ("Use maxExtensionSize somewhere")]
protected static void LoadElementExtensions (XmlReader reader, Workspace workspace, int maxExtensionSize)
{
workspace.ElementExtensions.Add (reader);
}
protected static bool TryParseAttribute (string name, string ns, string value, CategoriesDocument categories, string version)
{
return categories.TryParseAttribute (name, ns, value, version);
}
protected static bool TryParseAttribute (string name, string ns, string value, ResourceCollectionInfo collection, string version)
{
return collection.TryParseAttribute (name, ns, value, version);
}
protected static bool TryParseAttribute (string name, string ns, string value, ServiceDocument document, string version)
{
return document.TryParseAttribute (name, ns, value, version);
}
protected static bool TryParseAttribute (string name, string ns, string value, Workspace workspace, string version)
{
return workspace.TryParseAttribute (name, ns, value, version);
}
protected static bool TryParseElement (XmlReader reader, CategoriesDocument categories, string version)
{
return categories.TryParseElement (reader, version);
}
protected static bool TryParseElement (XmlReader reader, ResourceCollectionInfo collection, string version)
{
return collection.TryParseElement (reader, version);
}
protected static bool TryParseElement (XmlReader reader, ServiceDocument document, string version)
{
return document.TryParseElement (reader, version);
}
protected static bool TryParseElement (XmlReader reader, Workspace workspace, string version)
{
return workspace.TryParseElement (reader, version);
}
protected static void WriteAttributeExtensions (XmlWriter writer, CategoriesDocument categories, string version)
{
categories.WriteAttributeExtensions (writer, version);
}
protected static void WriteAttributeExtensions (XmlWriter writer, ResourceCollectionInfo collection, string version)
{
collection.WriteAttributeExtensions (writer, version);
}
protected static void WriteAttributeExtensions (XmlWriter writer, ServiceDocument document, string version)
{
document.WriteAttributeExtensions (writer, version);
}
protected static void WriteAttributeExtensions (XmlWriter writer, Workspace workspace, string version)
{
workspace.WriteAttributeExtensions (writer, version);
}
protected static void WriteElementExtensions (XmlWriter writer, CategoriesDocument categories, string version)
{
categories.WriteElementExtensions (writer, version);
}
protected static void WriteElementExtensions (XmlWriter writer, ResourceCollectionInfo collection, string version)
{
collection.WriteElementExtensions (writer, version);
}
protected static void WriteElementExtensions (XmlWriter writer, ServiceDocument document, string version)
{
document.WriteElementExtensions (writer, version);
}
protected static void WriteElementExtensions (XmlWriter writer, Workspace workspace, string version)
{
workspace.WriteElementExtensions (writer, version);
}
// instance members
protected ServiceDocumentFormatter ()
: this (new ServiceDocument ())
{
}
protected ServiceDocumentFormatter (ServiceDocument documentToWrite)
{
SetDocument (documentToWrite);
}
public ServiceDocument Document { get; private set; }
public abstract string Version { get; }
public abstract bool CanRead (XmlReader reader);
protected virtual ServiceDocument CreateDocumentInstance ()
{
return new ServiceDocument () { InternalFormatter = this };
}
public abstract void ReadFrom (XmlReader reader);
protected virtual void SetDocument (ServiceDocument document)
{
if (document == null)
throw new ArgumentNullException ("document");
Document = document;
}
public abstract void WriteTo (XmlWriter writer);
}
}

Some files were not shown because too many files have changed in this diff Show More