Imported Upstream version 5.16.0.100

Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-08-07 15:19:03 +00:00
parent 0a9828183b
commit 7d7f676260
4419 changed files with 170950 additions and 90273 deletions

View File

@@ -1,59 +0,0 @@
//
// 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

@@ -1,59 +0,0 @@
//
// 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

@@ -1,202 +0,0 @@
//
// 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

@@ -1,173 +0,0 @@
//
// 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

@@ -1,55 +0,0 @@
//
// 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

@@ -1,144 +0,0 @@
//
// 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

@@ -1,79 +0,0 @@
//
// 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

@@ -1,42 +0,0 @@
//
// 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

@@ -1,70 +0,0 @@
//
// 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

@@ -1,49 +0,0 @@
//
// 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

@@ -1,160 +0,0 @@
//
// 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

@@ -1,66 +0,0 @@
//
// 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

@@ -1,66 +0,0 @@
//
// 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

@@ -1,174 +0,0 @@
//
// 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

@@ -1,205 +0,0 @@
//
// 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);
}
}

View File

@@ -1,117 +0,0 @@
//
// SyndicationCategory.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;
namespace System.ServiceModel.Syndication
{
public class SyndicationCategory : ISyndicationElement
{
string name, scheme, label;
SyndicationExtensions extensions = new SyndicationExtensions ();
public SyndicationCategory ()
{
}
public SyndicationCategory (string name)
{
Name = name;
}
public SyndicationCategory (string name, string scheme, string label)
{
Name = name;
Scheme = scheme;
Label = label;
}
protected SyndicationCategory (SyndicationCategory source)
{
if (source == null)
throw new ArgumentNullException ("source");
name = source.name;
scheme = source.scheme;
label = source.label;
extensions = source.extensions.Clone ();
}
public Dictionary<XmlQualifiedName, string> AttributeExtensions {
get { return extensions.Attributes; }
}
public SyndicationElementExtensionCollection ElementExtensions {
get { return extensions.Elements; }
}
public string Label {
get { return label; }
set { label = value; }
}
public string Name {
get { return name; }
set { name = value; }
}
public string Scheme {
get { return scheme; }
set { scheme = value; }
}
public virtual SyndicationCategory Clone ()
{
return new SyndicationCategory (this);
}
protected internal virtual bool TryParseAttribute (string name, string ns, string value, string version)
{
return false;
}
protected internal virtual bool TryParseElement (XmlReader reader, string version)
{
return false;
}
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);
}
}
}

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