You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@@ -0,0 +1,19 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
static class App10Constants
|
||||
{
|
||||
public const string Accept = "accept";
|
||||
public const string Categories = "categories";
|
||||
public const string Collection = "collection";
|
||||
public const string Fixed = "fixed";
|
||||
public const string Href = "href";
|
||||
public const string Namespace = "http://www.w3.org/2007/app";
|
||||
public const string Prefix = "app";
|
||||
public const string Service = "service";
|
||||
public const string Workspace = "workspace";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
static class Atom10Constants
|
||||
{
|
||||
public const string AlternateTag = "alternate";
|
||||
public const string Atom10Namespace = "http://www.w3.org/2005/Atom";
|
||||
public const string Atom10Prefix = "a10";
|
||||
public const string AtomMediaType = "application/atom+xml";
|
||||
public const string AuthorTag = "author";
|
||||
public const string CategoryTag = "category";
|
||||
public const string ContentTag = "content";
|
||||
public const string ContributorTag = "contributor";
|
||||
public const string EmailTag = "email";
|
||||
public const string EntryTag = "entry";
|
||||
public const string FeedTag = "feed";
|
||||
public const string GeneratorTag = "generator";
|
||||
public const string HrefTag = "href";
|
||||
public const string HtmlMediaType = "text/html";
|
||||
public const string HtmlType = "html";
|
||||
public const string IdTag = "id";
|
||||
public const string LabelTag = "label";
|
||||
public const string LengthTag = "length";
|
||||
public const string LinkTag = "link";
|
||||
public const string LogoTag = "logo";
|
||||
public const string NameTag = "name";
|
||||
public const string PlaintextType = "text";
|
||||
public const string PublishedTag = "published";
|
||||
public const string RelativeTag = "rel";
|
||||
public const string RightsTag = "rights";
|
||||
public const string SchemeTag = "scheme";
|
||||
public const string SelfTag = "self";
|
||||
public const string SourceFeedTag = "source";
|
||||
public const string SourceTag = "src";
|
||||
public const string SpecificationLink = "http://atompub.org/2005/08/17/draft-ietf-atompub-format-11.html";
|
||||
public const string SubtitleTag = "subtitle";
|
||||
public const string SummaryTag = "summary";
|
||||
public const string TermTag = "term";
|
||||
public const string TitleTag = "title";
|
||||
public const string TypeTag = "type";
|
||||
public const string UpdatedTag = "updated";
|
||||
public const string UriTag = "uri";
|
||||
public const string XHtmlMediaType = "application/xhtml+xml";
|
||||
public const string XHtmlType = "xhtml";
|
||||
public const string XmlMediaType = "text/xml";
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,198 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Xml.Schema;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
[XmlRoot(ElementName = Atom10Constants.EntryTag, Namespace = Atom10Constants.Atom10Namespace)]
|
||||
public class Atom10ItemFormatter : SyndicationItemFormatter, IXmlSerializable
|
||||
{
|
||||
Atom10FeedFormatter feedSerializer;
|
||||
Type itemType;
|
||||
bool preserveAttributeExtensions;
|
||||
bool preserveElementExtensions;
|
||||
|
||||
public Atom10ItemFormatter()
|
||||
: this(typeof(SyndicationItem))
|
||||
{
|
||||
}
|
||||
|
||||
public Atom10ItemFormatter(Type itemTypeToCreate)
|
||||
: base()
|
||||
{
|
||||
if (itemTypeToCreate == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("itemTypeToCreate");
|
||||
}
|
||||
if (!typeof(SyndicationItem).IsAssignableFrom(itemTypeToCreate))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("itemTypeToCreate",
|
||||
SR.GetString(SR.InvalidObjectTypePassed, "itemTypeToCreate", "SyndicationItem"));
|
||||
}
|
||||
this.feedSerializer = new Atom10FeedFormatter();
|
||||
this.feedSerializer.PreserveAttributeExtensions = this.preserveAttributeExtensions = true;
|
||||
this.feedSerializer.PreserveElementExtensions = this.preserveElementExtensions = true;
|
||||
this.itemType = itemTypeToCreate;
|
||||
}
|
||||
|
||||
public Atom10ItemFormatter(SyndicationItem itemToWrite)
|
||||
: base(itemToWrite)
|
||||
{
|
||||
// No need to check that the parameter passed is valid - it is checked by the c'tor of the base class
|
||||
this.feedSerializer = new Atom10FeedFormatter();
|
||||
this.feedSerializer.PreserveAttributeExtensions = this.preserveAttributeExtensions = true;
|
||||
this.feedSerializer.PreserveElementExtensions = this.preserveElementExtensions = true;
|
||||
this.itemType = itemToWrite.GetType();
|
||||
}
|
||||
|
||||
public bool PreserveAttributeExtensions
|
||||
{
|
||||
get { return this.preserveAttributeExtensions; }
|
||||
set
|
||||
{
|
||||
this.preserveAttributeExtensions = value;
|
||||
this.feedSerializer.PreserveAttributeExtensions = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool PreserveElementExtensions
|
||||
{
|
||||
get { return this.preserveElementExtensions; }
|
||||
set
|
||||
{
|
||||
this.preserveElementExtensions = value;
|
||||
this.feedSerializer.PreserveElementExtensions = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Version
|
||||
{
|
||||
get { return SyndicationVersions.Atom10; }
|
||||
}
|
||||
|
||||
protected Type ItemType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.itemType;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanRead(XmlReader reader)
|
||||
{
|
||||
if (reader == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
|
||||
}
|
||||
return reader.IsStartElement(Atom10Constants.EntryTag, Atom10Constants.Atom10Namespace);
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
|
||||
XmlSchema IXmlSerializable.GetSchema()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
|
||||
void IXmlSerializable.ReadXml(XmlReader reader)
|
||||
{
|
||||
if (reader == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
|
||||
}
|
||||
SyndicationFeedFormatter.TraceItemReadBegin();
|
||||
ReadItem(reader);
|
||||
SyndicationFeedFormatter.TraceItemReadEnd();
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
|
||||
void IXmlSerializable.WriteXml(XmlWriter writer)
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
|
||||
}
|
||||
SyndicationFeedFormatter.TraceItemWriteBegin();
|
||||
WriteItem(writer);
|
||||
SyndicationFeedFormatter.TraceItemWriteEnd();
|
||||
}
|
||||
|
||||
public override void ReadFrom(XmlReader reader)
|
||||
{
|
||||
SyndicationFeedFormatter.TraceItemReadBegin();
|
||||
if (!CanRead(reader))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.UnknownItemXml, reader.LocalName, reader.NamespaceURI)));
|
||||
}
|
||||
ReadItem(reader);
|
||||
SyndicationFeedFormatter.TraceItemReadEnd();
|
||||
}
|
||||
|
||||
public override void WriteTo(XmlWriter writer)
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
|
||||
}
|
||||
SyndicationFeedFormatter.TraceItemWriteBegin();
|
||||
writer.WriteStartElement(Atom10Constants.EntryTag, Atom10Constants.Atom10Namespace);
|
||||
WriteItem(writer);
|
||||
writer.WriteEndElement();
|
||||
SyndicationFeedFormatter.TraceItemWriteEnd();
|
||||
}
|
||||
|
||||
protected override SyndicationItem CreateItemInstance()
|
||||
{
|
||||
return SyndicationItemFormatter.CreateItemInstance(this.itemType);
|
||||
}
|
||||
|
||||
void ReadItem(XmlReader reader)
|
||||
{
|
||||
SetItem(CreateItemInstance());
|
||||
feedSerializer.ReadItemFrom(XmlDictionaryReader.CreateDictionaryReader(reader), this.Item);
|
||||
}
|
||||
|
||||
void WriteItem(XmlWriter writer)
|
||||
{
|
||||
if (this.Item == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ItemFormatterDoesNotHaveItem)));
|
||||
}
|
||||
XmlDictionaryWriter w = XmlDictionaryWriter.CreateDictionaryWriter(writer);
|
||||
feedSerializer.WriteItemContents(w, this.Item);
|
||||
}
|
||||
}
|
||||
|
||||
[TypeForwardedFrom("System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
[XmlRoot(ElementName = Atom10Constants.EntryTag, Namespace = Atom10Constants.Atom10Namespace)]
|
||||
public class Atom10ItemFormatter<TSyndicationItem> : Atom10ItemFormatter
|
||||
where TSyndicationItem : SyndicationItem, new ()
|
||||
{
|
||||
// constructors
|
||||
public Atom10ItemFormatter()
|
||||
: base(typeof(TSyndicationItem))
|
||||
{
|
||||
}
|
||||
public Atom10ItemFormatter(TSyndicationItem itemToWrite)
|
||||
: base(itemToWrite)
|
||||
{
|
||||
}
|
||||
|
||||
protected override SyndicationItem CreateItemInstance()
|
||||
{
|
||||
return new TSyndicationItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
[XmlRoot(ElementName = App10Constants.Categories, Namespace = App10Constants.Namespace)]
|
||||
public class AtomPub10CategoriesDocumentFormatter : CategoriesDocumentFormatter, IXmlSerializable
|
||||
{
|
||||
Type inlineDocumentType;
|
||||
int maxExtensionSize;
|
||||
bool preserveAttributeExtensions;
|
||||
bool preserveElementExtensions;
|
||||
Type referencedDocumentType;
|
||||
|
||||
public AtomPub10CategoriesDocumentFormatter()
|
||||
: this(typeof(InlineCategoriesDocument), typeof(ReferencedCategoriesDocument))
|
||||
{
|
||||
}
|
||||
|
||||
public AtomPub10CategoriesDocumentFormatter(Type inlineDocumentType, Type referencedDocumentType)
|
||||
: base()
|
||||
{
|
||||
if (inlineDocumentType == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("inlineDocumentType");
|
||||
}
|
||||
if (!typeof(InlineCategoriesDocument).IsAssignableFrom(inlineDocumentType))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("inlineDocumentType",
|
||||
SR.GetString(SR.InvalidObjectTypePassed, "inlineDocumentType", "InlineCategoriesDocument"));
|
||||
}
|
||||
if (referencedDocumentType == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("referencedDocumentType");
|
||||
}
|
||||
if (!typeof(ReferencedCategoriesDocument).IsAssignableFrom(referencedDocumentType))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("referencedDocumentType",
|
||||
SR.GetString(SR.InvalidObjectTypePassed, "referencedDocumentType", "ReferencedCategoriesDocument"));
|
||||
}
|
||||
this.maxExtensionSize = int.MaxValue;
|
||||
this.preserveAttributeExtensions = true;
|
||||
this.preserveElementExtensions = true;
|
||||
this.inlineDocumentType = inlineDocumentType;
|
||||
this.referencedDocumentType = referencedDocumentType;
|
||||
}
|
||||
|
||||
public AtomPub10CategoriesDocumentFormatter(CategoriesDocument documentToWrite)
|
||||
: base(documentToWrite)
|
||||
{
|
||||
// No need to check that the parameter passed is valid - it is checked by the c'tor of the base class
|
||||
this.maxExtensionSize = int.MaxValue;
|
||||
preserveAttributeExtensions = true;
|
||||
preserveElementExtensions = true;
|
||||
if (documentToWrite.IsInline)
|
||||
{
|
||||
this.inlineDocumentType = documentToWrite.GetType();
|
||||
this.referencedDocumentType = typeof(ReferencedCategoriesDocument);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.referencedDocumentType = documentToWrite.GetType();
|
||||
this.inlineDocumentType = typeof(InlineCategoriesDocument);
|
||||
}
|
||||
}
|
||||
|
||||
public override string Version
|
||||
{
|
||||
get { return App10Constants.Namespace; }
|
||||
}
|
||||
|
||||
public override bool CanRead(XmlReader reader)
|
||||
{
|
||||
if (reader == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
|
||||
}
|
||||
return reader.IsStartElement(App10Constants.Categories, App10Constants.Namespace);
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
|
||||
XmlSchema IXmlSerializable.GetSchema()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
|
||||
void IXmlSerializable.ReadXml(XmlReader reader)
|
||||
{
|
||||
if (reader == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
|
||||
}
|
||||
TraceCategoriesDocumentReadBegin();
|
||||
ReadDocument(reader);
|
||||
TraceCategoriesDocumentReadEnd();
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
|
||||
void IXmlSerializable.WriteXml(XmlWriter writer)
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
|
||||
}
|
||||
if (this.Document == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.DocumentFormatterDoesNotHaveDocument)));
|
||||
}
|
||||
TraceCategoriesDocumentWriteBegin();
|
||||
WriteDocument(writer);
|
||||
TraceCategoriesDocumentWriteEnd();
|
||||
}
|
||||
|
||||
public override void ReadFrom(XmlReader reader)
|
||||
{
|
||||
if (reader == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
|
||||
}
|
||||
if (!CanRead(reader))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.UnknownDocumentXml, reader.LocalName, reader.NamespaceURI)));
|
||||
}
|
||||
TraceCategoriesDocumentReadBegin();
|
||||
ReadDocument(reader);
|
||||
TraceCategoriesDocumentReadEnd();
|
||||
}
|
||||
|
||||
public override void WriteTo(XmlWriter writer)
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
|
||||
}
|
||||
if (this.Document == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.DocumentFormatterDoesNotHaveDocument)));
|
||||
}
|
||||
TraceCategoriesDocumentWriteBegin();
|
||||
writer.WriteStartElement(App10Constants.Prefix, App10Constants.Categories, App10Constants.Namespace);
|
||||
WriteDocument(writer);
|
||||
writer.WriteEndElement();
|
||||
TraceCategoriesDocumentWriteEnd();
|
||||
}
|
||||
|
||||
internal static void TraceCategoriesDocumentReadBegin()
|
||||
{
|
||||
if (DiagnosticUtility.ShouldTraceInformation)
|
||||
{
|
||||
TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.SyndicationReadCategoriesDocumentBegin, SR.GetString(SR.TraceCodeSyndicationReadCategoriesDocumentBegin));
|
||||
}
|
||||
}
|
||||
|
||||
internal static void TraceCategoriesDocumentReadEnd()
|
||||
{
|
||||
if (DiagnosticUtility.ShouldTraceInformation)
|
||||
{
|
||||
TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.SyndicationReadCategoriesDocumentEnd, SR.GetString(SR.TraceCodeSyndicationReadCategoriesDocumentEnd));
|
||||
}
|
||||
}
|
||||
|
||||
internal static void TraceCategoriesDocumentWriteBegin()
|
||||
{
|
||||
if (DiagnosticUtility.ShouldTraceInformation)
|
||||
{
|
||||
TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.SyndicationWriteCategoriesDocumentBegin, SR.GetString(SR.TraceCodeSyndicationWriteCategoriesDocumentBegin));
|
||||
}
|
||||
}
|
||||
|
||||
internal static void TraceCategoriesDocumentWriteEnd()
|
||||
{
|
||||
if (DiagnosticUtility.ShouldTraceInformation)
|
||||
{
|
||||
TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.SyndicationWriteCategoriesDocumentEnd, SR.GetString(SR.TraceCodeSyndicationWriteCategoriesDocumentEnd));
|
||||
}
|
||||
}
|
||||
|
||||
protected override InlineCategoriesDocument CreateInlineCategoriesDocument()
|
||||
{
|
||||
if (inlineDocumentType == typeof(InlineCategoriesDocument))
|
||||
{
|
||||
return new InlineCategoriesDocument();
|
||||
}
|
||||
else
|
||||
{
|
||||
return (InlineCategoriesDocument)Activator.CreateInstance(this.inlineDocumentType);
|
||||
}
|
||||
}
|
||||
|
||||
protected override ReferencedCategoriesDocument CreateReferencedCategoriesDocument()
|
||||
{
|
||||
if (referencedDocumentType == typeof(ReferencedCategoriesDocument))
|
||||
{
|
||||
return new ReferencedCategoriesDocument();
|
||||
}
|
||||
else
|
||||
{
|
||||
return (ReferencedCategoriesDocument)Activator.CreateInstance(this.referencedDocumentType);
|
||||
}
|
||||
}
|
||||
|
||||
void ReadDocument(XmlReader reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
SyndicationFeedFormatter.MoveToStartElement(reader);
|
||||
SetDocument(AtomPub10ServiceDocumentFormatter.ReadCategories(reader, null,
|
||||
delegate()
|
||||
{
|
||||
return this.CreateInlineCategoriesDocument();
|
||||
},
|
||||
|
||||
delegate()
|
||||
{
|
||||
return this.CreateReferencedCategoriesDocument();
|
||||
},
|
||||
this.Version,
|
||||
this.preserveElementExtensions,
|
||||
this.preserveAttributeExtensions,
|
||||
this.maxExtensionSize));
|
||||
}
|
||||
catch (FormatException e)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(FeedUtils.AddLineInfo(reader, SR.ErrorParsingDocument), e));
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(FeedUtils.AddLineInfo(reader, SR.ErrorParsingDocument), e));
|
||||
}
|
||||
}
|
||||
|
||||
void WriteDocument(XmlWriter writer)
|
||||
{
|
||||
// declare the atom10 namespace upfront for compactness
|
||||
writer.WriteAttributeString(Atom10Constants.Atom10Prefix, Atom10FeedFormatter.XmlNsNs, Atom10Constants.Atom10Namespace);
|
||||
AtomPub10ServiceDocumentFormatter.WriteCategoriesInnerXml(writer, this.Document, null, this.Version);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,121 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System.Xml;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
public abstract class CategoriesDocument : IExtensibleSyndicationObject
|
||||
{
|
||||
Uri baseUri;
|
||||
ExtensibleSyndicationObject extensions = new ExtensibleSyndicationObject();
|
||||
string language;
|
||||
|
||||
internal CategoriesDocument()
|
||||
{
|
||||
}
|
||||
|
||||
public Dictionary<XmlQualifiedName, string> AttributeExtensions
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extensions.AttributeExtensions;
|
||||
}
|
||||
}
|
||||
|
||||
public Uri BaseUri
|
||||
{
|
||||
get { return this.baseUri; }
|
||||
set { this.baseUri = value; }
|
||||
}
|
||||
|
||||
public SyndicationElementExtensionCollection ElementExtensions
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extensions.ElementExtensions;
|
||||
}
|
||||
}
|
||||
|
||||
public string Language
|
||||
{
|
||||
get { return this.language; }
|
||||
set { this.language = value; }
|
||||
}
|
||||
|
||||
internal abstract bool IsInline
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public static InlineCategoriesDocument Create(Collection<SyndicationCategory> categories)
|
||||
{
|
||||
return new InlineCategoriesDocument(categories);
|
||||
}
|
||||
|
||||
public static InlineCategoriesDocument Create(Collection<SyndicationCategory> categories, bool isFixed, string scheme)
|
||||
{
|
||||
return new InlineCategoriesDocument(categories, isFixed, scheme);
|
||||
}
|
||||
|
||||
public static ReferencedCategoriesDocument Create(Uri linkToCategoriesDocument)
|
||||
{
|
||||
return new ReferencedCategoriesDocument(linkToCategoriesDocument);
|
||||
}
|
||||
|
||||
public static CategoriesDocument Load(XmlReader reader)
|
||||
{
|
||||
AtomPub10CategoriesDocumentFormatter formatter = new AtomPub10CategoriesDocumentFormatter();
|
||||
formatter.ReadFrom(reader);
|
||||
return formatter.Document;
|
||||
}
|
||||
|
||||
public CategoriesDocumentFormatter GetFormatter()
|
||||
{
|
||||
return new AtomPub10CategoriesDocumentFormatter(this);
|
||||
}
|
||||
|
||||
public void Save(XmlWriter writer)
|
||||
{
|
||||
this.GetFormatter().WriteTo(writer);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
this.extensions.WriteAttributeExtensions(writer);
|
||||
}
|
||||
|
||||
protected internal virtual void WriteElementExtensions(XmlWriter writer, string version)
|
||||
{
|
||||
this.extensions.WriteElementExtensions(writer);
|
||||
}
|
||||
|
||||
internal void LoadElementExtensions(XmlReader readerOverUnparsedExtensions, int maxExtensionSize)
|
||||
{
|
||||
this.extensions.LoadElementExtensions(readerOverUnparsedExtensions, maxExtensionSize);
|
||||
}
|
||||
|
||||
internal void LoadElementExtensions(XmlBuffer buffer)
|
||||
{
|
||||
this.extensions.LoadElementExtensions(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
[DataContract]
|
||||
public abstract class CategoriesDocumentFormatter
|
||||
{
|
||||
CategoriesDocument document;
|
||||
|
||||
protected CategoriesDocumentFormatter()
|
||||
{
|
||||
}
|
||||
protected CategoriesDocumentFormatter(CategoriesDocument documentToWrite)
|
||||
{
|
||||
if (documentToWrite == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("documentToWrite");
|
||||
}
|
||||
this.document = documentToWrite;
|
||||
}
|
||||
|
||||
public CategoriesDocument Document
|
||||
{
|
||||
get { return this.document; }
|
||||
}
|
||||
|
||||
public abstract string Version
|
||||
{ get; }
|
||||
|
||||
public abstract bool CanRead(XmlReader reader);
|
||||
public abstract void ReadFrom(XmlReader reader);
|
||||
public abstract void WriteTo(XmlWriter writer);
|
||||
|
||||
protected virtual InlineCategoriesDocument CreateInlineCategoriesDocument()
|
||||
{
|
||||
return new InlineCategoriesDocument();
|
||||
}
|
||||
|
||||
protected virtual ReferencedCategoriesDocument CreateReferencedCategoriesDocument()
|
||||
{
|
||||
return new ReferencedCategoriesDocument();
|
||||
}
|
||||
|
||||
protected virtual void SetDocument(CategoriesDocument document)
|
||||
{
|
||||
this.document = document;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
|
||||
// NOTE: This class implements Clone so if you add any members, please update the copy ctor
|
||||
struct ExtensibleSyndicationObject : IExtensibleSyndicationObject
|
||||
{
|
||||
Dictionary<XmlQualifiedName, string> attributeExtensions;
|
||||
SyndicationElementExtensionCollection elementExtensions;
|
||||
|
||||
ExtensibleSyndicationObject(ExtensibleSyndicationObject source)
|
||||
{
|
||||
if (source.attributeExtensions != null)
|
||||
{
|
||||
this.attributeExtensions = new Dictionary<XmlQualifiedName, string>();
|
||||
foreach (XmlQualifiedName key in source.attributeExtensions.Keys)
|
||||
{
|
||||
this.attributeExtensions.Add(key, source.attributeExtensions[key]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.attributeExtensions = null;
|
||||
}
|
||||
if (source.elementExtensions != null)
|
||||
{
|
||||
this.elementExtensions = new SyndicationElementExtensionCollection(source.elementExtensions);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.elementExtensions = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<XmlQualifiedName, string> AttributeExtensions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.attributeExtensions == null)
|
||||
{
|
||||
this.attributeExtensions = new Dictionary<XmlQualifiedName, string>();
|
||||
}
|
||||
return this.attributeExtensions;
|
||||
}
|
||||
}
|
||||
|
||||
public SyndicationElementExtensionCollection ElementExtensions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.elementExtensions == null)
|
||||
{
|
||||
this.elementExtensions = new SyndicationElementExtensionCollection();
|
||||
}
|
||||
return this.elementExtensions;
|
||||
}
|
||||
}
|
||||
|
||||
static XmlBuffer CreateXmlBuffer(XmlDictionaryReader unparsedExtensionsReader, int maxExtensionSize)
|
||||
{
|
||||
XmlBuffer buffer = new XmlBuffer(maxExtensionSize);
|
||||
using (XmlDictionaryWriter writer = buffer.OpenSection(unparsedExtensionsReader.Quotas))
|
||||
{
|
||||
writer.WriteStartElement(Rss20Constants.ExtensionWrapperTag);
|
||||
while (unparsedExtensionsReader.IsStartElement())
|
||||
{
|
||||
writer.WriteNode(unparsedExtensionsReader, false);
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
buffer.CloseSection();
|
||||
buffer.Close();
|
||||
return buffer;
|
||||
}
|
||||
|
||||
internal void LoadElementExtensions(XmlReader readerOverUnparsedExtensions, int maxExtensionSize)
|
||||
{
|
||||
if (readerOverUnparsedExtensions == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("readerOverUnparsedExtensions");
|
||||
}
|
||||
if (maxExtensionSize < 0)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maxExtensionSize"));
|
||||
}
|
||||
XmlDictionaryReader r = XmlDictionaryReader.CreateDictionaryReader(readerOverUnparsedExtensions);
|
||||
this.elementExtensions = new SyndicationElementExtensionCollection(CreateXmlBuffer(r, maxExtensionSize));
|
||||
}
|
||||
|
||||
|
||||
internal void LoadElementExtensions(XmlBuffer buffer)
|
||||
{
|
||||
this.elementExtensions = new SyndicationElementExtensionCollection(buffer);
|
||||
}
|
||||
|
||||
internal void WriteAttributeExtensions(XmlWriter writer)
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
|
||||
}
|
||||
if (this.attributeExtensions != null)
|
||||
{
|
||||
foreach (XmlQualifiedName qname in this.attributeExtensions.Keys)
|
||||
{
|
||||
string value = this.attributeExtensions[qname];
|
||||
writer.WriteAttributeString(qname.Name, qname.Namespace, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void WriteElementExtensions(XmlWriter writer)
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
|
||||
}
|
||||
if (this.elementExtensions != null)
|
||||
{
|
||||
this.elementExtensions.WriteTo(writer);
|
||||
}
|
||||
}
|
||||
|
||||
public ExtensibleSyndicationObject Clone()
|
||||
{
|
||||
return new ExtensibleSyndicationObject(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Globalization;
|
||||
|
||||
static class FeedUtils
|
||||
{
|
||||
public static string AddLineInfo(XmlReader reader, string error)
|
||||
{
|
||||
IXmlLineInfo lineInfo = reader as IXmlLineInfo;
|
||||
if (lineInfo != null && lineInfo.HasLineInfo())
|
||||
{
|
||||
error = String.Format(CultureInfo.InvariantCulture, "{0} {1}", SR.GetString(SR.ErrorInLine, lineInfo.LineNumber, lineInfo.LinePosition), SR.GetString(error));
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
static internal Collection<SyndicationCategory> CloneCategories(Collection<SyndicationCategory> categories)
|
||||
{
|
||||
if (categories == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Collection<SyndicationCategory> result = new NullNotAllowedCollection<SyndicationCategory>();
|
||||
for (int i = 0; i < categories.Count; ++i)
|
||||
{
|
||||
result.Add(categories[i].Clone());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static internal Collection<SyndicationLink> CloneLinks(Collection<SyndicationLink> links)
|
||||
{
|
||||
if (links == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Collection<SyndicationLink> result = new NullNotAllowedCollection<SyndicationLink>();
|
||||
for (int i = 0; i < links.Count; ++i)
|
||||
{
|
||||
result.Add(links[i].Clone());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static internal Collection<SyndicationPerson> ClonePersons(Collection<SyndicationPerson> persons)
|
||||
{
|
||||
if (persons == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Collection<SyndicationPerson> result = new NullNotAllowedCollection<SyndicationPerson>();
|
||||
for (int i = 0; i < persons.Count; ++i)
|
||||
{
|
||||
result.Add(persons[i].Clone());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static internal TextSyndicationContent CloneTextContent(TextSyndicationContent content)
|
||||
{
|
||||
if (content == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (TextSyndicationContent)(content.Clone());
|
||||
}
|
||||
|
||||
internal static Uri CombineXmlBase(Uri rootBase, string newBase)
|
||||
{
|
||||
if (string.IsNullOrEmpty(newBase))
|
||||
{
|
||||
return rootBase;
|
||||
}
|
||||
Uri newBaseUri = new Uri(newBase, UriKind.RelativeOrAbsolute);
|
||||
if (rootBase == null || newBaseUri.IsAbsoluteUri)
|
||||
{
|
||||
return newBaseUri;
|
||||
}
|
||||
return new Uri(rootBase, newBase);
|
||||
}
|
||||
|
||||
internal static Uri GetBaseUriToWrite(Uri rootBase, Uri currentBase)
|
||||
{
|
||||
Uri uriToWrite;
|
||||
if (rootBase == currentBase || currentBase == null)
|
||||
{
|
||||
uriToWrite = null;
|
||||
}
|
||||
else if (rootBase == null)
|
||||
{
|
||||
uriToWrite = currentBase;
|
||||
}
|
||||
else
|
||||
{
|
||||
// rootBase != currentBase and both are not null
|
||||
// Write the relative base if possible
|
||||
if (rootBase.IsAbsoluteUri && currentBase.IsAbsoluteUri && rootBase.IsBaseOf(currentBase))
|
||||
{
|
||||
uriToWrite = rootBase.MakeRelativeUri(currentBase);
|
||||
}
|
||||
else
|
||||
{
|
||||
uriToWrite = currentBase;
|
||||
}
|
||||
}
|
||||
return uriToWrite;
|
||||
}
|
||||
|
||||
static internal string GetUriString(Uri uri)
|
||||
{
|
||||
if (uri == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (uri.IsAbsoluteUri)
|
||||
{
|
||||
return uri.AbsoluteUri;
|
||||
}
|
||||
else
|
||||
{
|
||||
return uri.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
static internal bool IsXmlns(string name, string ns)
|
||||
{
|
||||
return name == "xmlns" || ns == "http://www.w3.org/2000/xmlns/";
|
||||
}
|
||||
|
||||
internal static bool IsXmlSchemaType(string name, string ns)
|
||||
{
|
||||
return name == "type" && ns == "http://www.w3.org/2001/XMLSchema-instance";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
|
||||
interface IExtensibleSyndicationObject
|
||||
{
|
||||
Dictionary<XmlQualifiedName, string> AttributeExtensions
|
||||
{ get; }
|
||||
SyndicationElementExtensionCollection ElementExtensions
|
||||
{ get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System.Xml;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
public class InlineCategoriesDocument : CategoriesDocument
|
||||
{
|
||||
Collection<SyndicationCategory> categories;
|
||||
bool isFixed;
|
||||
string scheme;
|
||||
|
||||
public InlineCategoriesDocument()
|
||||
{
|
||||
}
|
||||
|
||||
public InlineCategoriesDocument(IEnumerable<SyndicationCategory> categories)
|
||||
: this(categories, false, null)
|
||||
{
|
||||
}
|
||||
|
||||
public InlineCategoriesDocument(IEnumerable<SyndicationCategory> categories, bool isFixed, string scheme)
|
||||
{
|
||||
if (categories != null)
|
||||
{
|
||||
this.categories = new NullNotAllowedCollection<SyndicationCategory>();
|
||||
foreach (SyndicationCategory category in categories)
|
||||
{
|
||||
this.categories.Add(category);
|
||||
}
|
||||
}
|
||||
this.isFixed = isFixed;
|
||||
this.scheme = scheme;
|
||||
}
|
||||
|
||||
public Collection<SyndicationCategory> Categories
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.categories == null)
|
||||
{
|
||||
this.categories = new NullNotAllowedCollection<SyndicationCategory>();
|
||||
}
|
||||
return this.categories;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsFixed
|
||||
{
|
||||
get { return this.isFixed; }
|
||||
set { this.isFixed = value; }
|
||||
}
|
||||
|
||||
public string Scheme
|
||||
{
|
||||
get { return this.scheme; }
|
||||
set { this.scheme = value; }
|
||||
}
|
||||
|
||||
internal override bool IsInline
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
internal protected virtual SyndicationCategory CreateCategory()
|
||||
{
|
||||
return new SyndicationCategory();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
class NullNotAllowedCollection<TCollectionItem> : Collection<TCollectionItem>
|
||||
where TCollectionItem : class
|
||||
{
|
||||
public NullNotAllowedCollection()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InsertItem(int index, TCollectionItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item");
|
||||
}
|
||||
base.InsertItem(index, item);
|
||||
}
|
||||
|
||||
protected override void SetItem(int index, TCollectionItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item");
|
||||
}
|
||||
base.SetItem(index, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System.Xml;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
public class ReferencedCategoriesDocument : CategoriesDocument
|
||||
{
|
||||
Uri link;
|
||||
|
||||
public ReferencedCategoriesDocument()
|
||||
{
|
||||
}
|
||||
|
||||
public ReferencedCategoriesDocument(Uri link)
|
||||
: base()
|
||||
{
|
||||
if (link == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("link");
|
||||
}
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
public Uri Link
|
||||
{
|
||||
get { return this.link; }
|
||||
set { this.link = value; }
|
||||
}
|
||||
|
||||
internal override bool IsInline
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
public class ResourceCollectionInfo : IExtensibleSyndicationObject
|
||||
{
|
||||
static IEnumerable<string> singleEmptyAccept;
|
||||
Collection<string> accepts;
|
||||
Uri baseUri;
|
||||
Collection<CategoriesDocument> categories;
|
||||
ExtensibleSyndicationObject extensions = new ExtensibleSyndicationObject();
|
||||
Uri link;
|
||||
TextSyndicationContent title;
|
||||
|
||||
public ResourceCollectionInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public ResourceCollectionInfo(string title, Uri link)
|
||||
: this((title == null) ? null : new TextSyndicationContent(title), link)
|
||||
{
|
||||
}
|
||||
|
||||
public ResourceCollectionInfo(TextSyndicationContent title, Uri link)
|
||||
: this(title, link, null, null)
|
||||
{
|
||||
}
|
||||
|
||||
public ResourceCollectionInfo(TextSyndicationContent title, Uri link, IEnumerable<CategoriesDocument> categories, bool allowsNewEntries)
|
||||
: this(title, link, categories, (allowsNewEntries) ? null : CreateSingleEmptyAccept())
|
||||
{
|
||||
}
|
||||
|
||||
public ResourceCollectionInfo(TextSyndicationContent title, Uri link, IEnumerable<CategoriesDocument> categories, IEnumerable<string> accepts)
|
||||
{
|
||||
if (title == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("title");
|
||||
}
|
||||
if (link == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("link");
|
||||
}
|
||||
this.title = title;
|
||||
this.link = link;
|
||||
if (categories != null)
|
||||
{
|
||||
this.categories = new NullNotAllowedCollection<CategoriesDocument>();
|
||||
foreach (CategoriesDocument category in categories)
|
||||
{
|
||||
this.categories.Add(category);
|
||||
}
|
||||
}
|
||||
if (accepts != null)
|
||||
{
|
||||
this.accepts = new NullNotAllowedCollection<string>();
|
||||
foreach (string accept in accepts)
|
||||
{
|
||||
this.accepts.Add(accept);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<string> Accepts
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.accepts == null)
|
||||
{
|
||||
this.accepts = new NullNotAllowedCollection<string>();
|
||||
}
|
||||
return this.accepts;
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<XmlQualifiedName, string> AttributeExtensions
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extensions.AttributeExtensions;
|
||||
}
|
||||
}
|
||||
|
||||
public Uri BaseUri
|
||||
{
|
||||
get { return this.baseUri; }
|
||||
set { this.baseUri = value; }
|
||||
}
|
||||
|
||||
public Collection<CategoriesDocument> Categories
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.categories == null)
|
||||
{
|
||||
this.categories = new NullNotAllowedCollection<CategoriesDocument>();
|
||||
}
|
||||
return this.categories;
|
||||
}
|
||||
}
|
||||
|
||||
public SyndicationElementExtensionCollection ElementExtensions
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extensions.ElementExtensions;
|
||||
}
|
||||
}
|
||||
|
||||
public Uri Link
|
||||
{
|
||||
get { return this.link; }
|
||||
set { this.link = value; }
|
||||
}
|
||||
|
||||
public TextSyndicationContent Title
|
||||
{
|
||||
get { return this.title; }
|
||||
set { this.title = value; }
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected internal virtual bool TryParseElement(XmlReader reader, string version)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected internal virtual void WriteAttributeExtensions(XmlWriter writer, string version)
|
||||
{
|
||||
this.extensions.WriteAttributeExtensions(writer);
|
||||
}
|
||||
|
||||
protected internal virtual void WriteElementExtensions(XmlWriter writer, string version)
|
||||
{
|
||||
this.extensions.WriteElementExtensions(writer);
|
||||
}
|
||||
|
||||
internal void LoadElementExtensions(XmlReader readerOverUnparsedExtensions, int maxExtensionSize)
|
||||
{
|
||||
this.extensions.LoadElementExtensions(readerOverUnparsedExtensions, maxExtensionSize);
|
||||
}
|
||||
|
||||
internal void LoadElementExtensions(XmlBuffer buffer)
|
||||
{
|
||||
this.extensions.LoadElementExtensions(buffer);
|
||||
}
|
||||
|
||||
static IEnumerable<string> CreateSingleEmptyAccept()
|
||||
{
|
||||
if (singleEmptyAccept == null)
|
||||
{
|
||||
List<string> tmp = new List<string>(1);
|
||||
tmp.Add(string.Empty);
|
||||
singleEmptyAccept = tmp.AsReadOnly();
|
||||
}
|
||||
return singleEmptyAccept;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
static class Rss20Constants
|
||||
{
|
||||
public const string AuthorTag = "author";
|
||||
public const string CategoryTag = "category";
|
||||
public const string ChannelTag = "channel";
|
||||
public const string CopyrightTag = "copyright";
|
||||
public const string DescriptionTag = "description";
|
||||
public const string DomainTag = "domain";
|
||||
public const string EnclosureTag = "enclosure";
|
||||
public const string ExtensionWrapperTag = "extensionWrapper";
|
||||
public const string GeneratorTag = "generator";
|
||||
public const string GuidTag = "guid";
|
||||
public const string ImageTag = "image";
|
||||
public const string IsPermaLinkTag = "isPermaLink";
|
||||
public const string ItemTag = "item";
|
||||
public const string LanguageTag = "language";
|
||||
public const string LastBuildDateTag = "lastBuildDate";
|
||||
public const string LengthTag = "length";
|
||||
public const string LinkTag = "link";
|
||||
public const string ManagingEditorTag = "managingEditor";
|
||||
public const string PubDateTag = "pubDate";
|
||||
public const string Rss20Namespace = "";
|
||||
public const string RssTag = "rss";
|
||||
public const string SourceTag = "source";
|
||||
public const string SpecificationLink = "http://blogs.law.harvard.edu/tech/rss";
|
||||
public const string TitleTag = "title";
|
||||
public const string TypeTag = "type";
|
||||
public const string UrlTag = "url";
|
||||
public const string Version = "2.0";
|
||||
public const string VersionTag = "version";
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,219 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Xml.Schema;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
[XmlRoot(ElementName = Rss20Constants.ItemTag, Namespace = Rss20Constants.Rss20Namespace)]
|
||||
public class Rss20ItemFormatter : SyndicationItemFormatter, IXmlSerializable
|
||||
{
|
||||
Rss20FeedFormatter feedSerializer;
|
||||
Type itemType;
|
||||
bool preserveAttributeExtensions;
|
||||
bool preserveElementExtensions;
|
||||
bool serializeExtensionsAsAtom;
|
||||
|
||||
public Rss20ItemFormatter()
|
||||
: this(typeof(SyndicationItem))
|
||||
{
|
||||
}
|
||||
|
||||
public Rss20ItemFormatter(Type itemTypeToCreate)
|
||||
: base()
|
||||
{
|
||||
if (itemTypeToCreate == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("itemTypeToCreate");
|
||||
}
|
||||
if (!typeof(SyndicationItem).IsAssignableFrom(itemTypeToCreate))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("itemTypeToCreate",
|
||||
SR.GetString(SR.InvalidObjectTypePassed, "itemTypeToCreate", "SyndicationItem"));
|
||||
}
|
||||
this.feedSerializer = new Rss20FeedFormatter();
|
||||
this.feedSerializer.PreserveAttributeExtensions = this.preserveAttributeExtensions = true;
|
||||
this.feedSerializer.PreserveElementExtensions = this.preserveElementExtensions = true;
|
||||
this.feedSerializer.SerializeExtensionsAsAtom = this.serializeExtensionsAsAtom = true;
|
||||
this.itemType = itemTypeToCreate;
|
||||
}
|
||||
|
||||
public Rss20ItemFormatter(SyndicationItem itemToWrite)
|
||||
: this(itemToWrite, true)
|
||||
{
|
||||
}
|
||||
|
||||
public Rss20ItemFormatter(SyndicationItem itemToWrite, bool serializeExtensionsAsAtom)
|
||||
: base(itemToWrite)
|
||||
{
|
||||
// No need to check that the parameter passed is valid - it is checked by the c'tor of the base class
|
||||
this.feedSerializer = new Rss20FeedFormatter();
|
||||
this.feedSerializer.PreserveAttributeExtensions = this.preserveAttributeExtensions = true;
|
||||
this.feedSerializer.PreserveElementExtensions = this.preserveElementExtensions = true;
|
||||
this.feedSerializer.SerializeExtensionsAsAtom = this.serializeExtensionsAsAtom = serializeExtensionsAsAtom;
|
||||
this.itemType = itemToWrite.GetType();
|
||||
}
|
||||
|
||||
public bool PreserveAttributeExtensions
|
||||
{
|
||||
get { return this.preserveAttributeExtensions; }
|
||||
set
|
||||
{
|
||||
this.preserveAttributeExtensions = value;
|
||||
this.feedSerializer.PreserveAttributeExtensions = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool PreserveElementExtensions
|
||||
{
|
||||
get { return this.preserveElementExtensions; }
|
||||
set
|
||||
{
|
||||
this.preserveElementExtensions = value;
|
||||
this.feedSerializer.PreserveElementExtensions = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SerializeExtensionsAsAtom
|
||||
{
|
||||
get { return this.serializeExtensionsAsAtom; }
|
||||
set
|
||||
{
|
||||
this.serializeExtensionsAsAtom = value;
|
||||
this.feedSerializer.SerializeExtensionsAsAtom = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Version
|
||||
{
|
||||
get { return SyndicationVersions.Rss20; }
|
||||
}
|
||||
|
||||
protected Type ItemType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.itemType;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanRead(XmlReader reader)
|
||||
{
|
||||
if (reader == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
|
||||
}
|
||||
return reader.IsStartElement(Rss20Constants.ItemTag, Rss20Constants.Rss20Namespace);
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
|
||||
XmlSchema IXmlSerializable.GetSchema()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
|
||||
void IXmlSerializable.ReadXml(XmlReader reader)
|
||||
{
|
||||
if (reader == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
|
||||
}
|
||||
SyndicationFeedFormatter.TraceItemReadBegin();
|
||||
ReadItem(reader);
|
||||
SyndicationFeedFormatter.TraceItemReadEnd();
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
|
||||
void IXmlSerializable.WriteXml(XmlWriter writer)
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
|
||||
}
|
||||
SyndicationFeedFormatter.TraceItemWriteBegin();
|
||||
WriteItem(writer);
|
||||
SyndicationFeedFormatter.TraceItemWriteEnd();
|
||||
}
|
||||
|
||||
public override void ReadFrom(XmlReader reader)
|
||||
{
|
||||
SyndicationFeedFormatter.TraceItemReadBegin();
|
||||
if (!CanRead(reader))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.UnknownItemXml, reader.LocalName, reader.NamespaceURI)));
|
||||
}
|
||||
ReadItem(reader);
|
||||
SyndicationFeedFormatter.TraceItemReadEnd();
|
||||
}
|
||||
|
||||
public override void WriteTo(XmlWriter writer)
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
|
||||
}
|
||||
SyndicationFeedFormatter.TraceItemWriteBegin();
|
||||
writer.WriteStartElement(Rss20Constants.ItemTag, Rss20Constants.Rss20Namespace);
|
||||
WriteItem(writer);
|
||||
writer.WriteEndElement();
|
||||
SyndicationFeedFormatter.TraceItemWriteEnd();
|
||||
}
|
||||
|
||||
protected override SyndicationItem CreateItemInstance()
|
||||
{
|
||||
return SyndicationItemFormatter.CreateItemInstance(this.itemType);
|
||||
}
|
||||
|
||||
void ReadItem(XmlReader reader)
|
||||
{
|
||||
SetItem(CreateItemInstance());
|
||||
feedSerializer.ReadItemFrom(XmlDictionaryReader.CreateDictionaryReader(reader), this.Item);
|
||||
}
|
||||
|
||||
void WriteItem(XmlWriter writer)
|
||||
{
|
||||
if (this.Item == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ItemFormatterDoesNotHaveItem)));
|
||||
}
|
||||
XmlDictionaryWriter w = XmlDictionaryWriter.CreateDictionaryWriter(writer);
|
||||
feedSerializer.WriteItemContents(w, this.Item);
|
||||
}
|
||||
}
|
||||
|
||||
[TypeForwardedFrom("System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
[XmlRoot(ElementName = Rss20Constants.ItemTag, Namespace = Rss20Constants.Rss20Namespace)]
|
||||
public class Rss20ItemFormatter<TSyndicationItem> : Rss20ItemFormatter, IXmlSerializable
|
||||
where TSyndicationItem : SyndicationItem, new ()
|
||||
{
|
||||
public Rss20ItemFormatter()
|
||||
: base(typeof(TSyndicationItem))
|
||||
{
|
||||
}
|
||||
public Rss20ItemFormatter(TSyndicationItem itemToWrite)
|
||||
: base(itemToWrite)
|
||||
{
|
||||
}
|
||||
public Rss20ItemFormatter(TSyndicationItem itemToWrite, bool serializeExtensionsAsAtom)
|
||||
: base(itemToWrite, serializeExtensionsAsAtom)
|
||||
{
|
||||
}
|
||||
|
||||
protected override SyndicationItem CreateItemInstance()
|
||||
{
|
||||
return new TSyndicationItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
public class ServiceDocument : IExtensibleSyndicationObject
|
||||
{
|
||||
Uri baseUri;
|
||||
ExtensibleSyndicationObject extensions = new ExtensibleSyndicationObject();
|
||||
string language;
|
||||
Collection<Workspace> workspaces;
|
||||
|
||||
public ServiceDocument() : this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public ServiceDocument(IEnumerable<Workspace> workspaces)
|
||||
{
|
||||
if (workspaces != null)
|
||||
{
|
||||
this.workspaces = new NullNotAllowedCollection<Workspace>();
|
||||
foreach (Workspace workspace in workspaces)
|
||||
{
|
||||
this.workspaces.Add(workspace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<XmlQualifiedName, string> AttributeExtensions
|
||||
{
|
||||
get { return this.extensions.AttributeExtensions; }
|
||||
}
|
||||
|
||||
public Uri BaseUri
|
||||
{
|
||||
get { return this.baseUri; }
|
||||
set { this.baseUri = value; }
|
||||
}
|
||||
|
||||
public SyndicationElementExtensionCollection ElementExtensions
|
||||
{
|
||||
get { return this.extensions.ElementExtensions; }
|
||||
}
|
||||
|
||||
public string Language
|
||||
{
|
||||
get { return this.language; }
|
||||
set { this.language = value; }
|
||||
}
|
||||
|
||||
public Collection<Workspace> Workspaces
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.workspaces == null)
|
||||
{
|
||||
this.workspaces = new NullNotAllowedCollection<Workspace>();
|
||||
}
|
||||
return this.workspaces;
|
||||
}
|
||||
}
|
||||
|
||||
public static ServiceDocument Load(XmlReader reader)
|
||||
{
|
||||
return Load<ServiceDocument>(reader);
|
||||
}
|
||||
|
||||
public static TServiceDocument Load<TServiceDocument>(XmlReader reader)
|
||||
where TServiceDocument : ServiceDocument, new ()
|
||||
{
|
||||
AtomPub10ServiceDocumentFormatter<TServiceDocument> formatter = new AtomPub10ServiceDocumentFormatter<TServiceDocument>();
|
||||
formatter.ReadFrom(reader);
|
||||
return (TServiceDocument)(object) formatter.Document;
|
||||
}
|
||||
|
||||
public ServiceDocumentFormatter GetFormatter()
|
||||
{
|
||||
return new AtomPub10ServiceDocumentFormatter(this);
|
||||
}
|
||||
|
||||
public void Save(XmlWriter writer)
|
||||
{
|
||||
new AtomPub10ServiceDocumentFormatter(this).WriteTo(writer);
|
||||
}
|
||||
|
||||
protected internal virtual Workspace CreateWorkspace()
|
||||
{
|
||||
return new Workspace();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
this.extensions.WriteAttributeExtensions(writer);
|
||||
}
|
||||
|
||||
protected internal virtual void WriteElementExtensions(XmlWriter writer, string version)
|
||||
{
|
||||
this.extensions.WriteElementExtensions(writer);
|
||||
}
|
||||
|
||||
internal void LoadElementExtensions(XmlReader readerOverUnparsedExtensions, int maxExtensionSize)
|
||||
{
|
||||
this.extensions.LoadElementExtensions(readerOverUnparsedExtensions, maxExtensionSize);
|
||||
}
|
||||
|
||||
internal void LoadElementExtensions(XmlBuffer buffer)
|
||||
{
|
||||
this.extensions.LoadElementExtensions(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
[DataContract]
|
||||
public abstract class ServiceDocumentFormatter
|
||||
{
|
||||
ServiceDocument document;
|
||||
|
||||
protected ServiceDocumentFormatter()
|
||||
{
|
||||
}
|
||||
protected ServiceDocumentFormatter(ServiceDocument documentToWrite)
|
||||
{
|
||||
if (documentToWrite == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("documentToWrite");
|
||||
}
|
||||
this.document = documentToWrite;
|
||||
}
|
||||
|
||||
public ServiceDocument Document
|
||||
{
|
||||
get { return this.document; }
|
||||
}
|
||||
|
||||
public abstract string Version
|
||||
{ get; }
|
||||
|
||||
public abstract bool CanRead(XmlReader reader);
|
||||
public abstract void ReadFrom(XmlReader reader);
|
||||
public abstract void WriteTo(XmlWriter writer);
|
||||
|
||||
internal static void LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, CategoriesDocument categories)
|
||||
{
|
||||
if (categories == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("categories");
|
||||
}
|
||||
Atom10FeedFormatter.CloseBuffer(buffer, writer);
|
||||
categories.LoadElementExtensions(buffer);
|
||||
}
|
||||
|
||||
internal static void LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, ResourceCollectionInfo collection)
|
||||
{
|
||||
if (collection == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("collection");
|
||||
}
|
||||
Atom10FeedFormatter.CloseBuffer(buffer, writer);
|
||||
collection.LoadElementExtensions(buffer);
|
||||
}
|
||||
|
||||
internal static void LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, Workspace workspace)
|
||||
{
|
||||
if (workspace == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workspace");
|
||||
}
|
||||
Atom10FeedFormatter.CloseBuffer(buffer, writer);
|
||||
workspace.LoadElementExtensions(buffer);
|
||||
}
|
||||
|
||||
internal static void LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, ServiceDocument document)
|
||||
{
|
||||
if (document == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("document");
|
||||
}
|
||||
Atom10FeedFormatter.CloseBuffer(buffer, writer);
|
||||
document.LoadElementExtensions(buffer);
|
||||
}
|
||||
|
||||
protected static SyndicationCategory CreateCategory(InlineCategoriesDocument inlineCategories)
|
||||
{
|
||||
if (inlineCategories == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("inlineCategories");
|
||||
}
|
||||
return inlineCategories.CreateCategory();
|
||||
}
|
||||
|
||||
protected static ResourceCollectionInfo CreateCollection(Workspace workspace)
|
||||
{
|
||||
if (workspace == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("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)
|
||||
{
|
||||
if (document == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("document");
|
||||
}
|
||||
return document.CreateWorkspace();
|
||||
}
|
||||
|
||||
protected static void LoadElementExtensions(XmlReader reader, CategoriesDocument categories, int maxExtensionSize)
|
||||
{
|
||||
if (categories == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("categories");
|
||||
}
|
||||
categories.LoadElementExtensions(reader, maxExtensionSize);
|
||||
}
|
||||
|
||||
protected static void LoadElementExtensions(XmlReader reader, ResourceCollectionInfo collection, int maxExtensionSize)
|
||||
{
|
||||
if (collection == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("collection");
|
||||
}
|
||||
collection.LoadElementExtensions(reader, maxExtensionSize);
|
||||
}
|
||||
|
||||
protected static void LoadElementExtensions(XmlReader reader, Workspace workspace, int maxExtensionSize)
|
||||
{
|
||||
if (workspace == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workspace");
|
||||
}
|
||||
workspace.LoadElementExtensions(reader, maxExtensionSize);
|
||||
}
|
||||
|
||||
protected static void LoadElementExtensions(XmlReader reader, ServiceDocument document, int maxExtensionSize)
|
||||
{
|
||||
if (document == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("document");
|
||||
}
|
||||
document.LoadElementExtensions(reader, maxExtensionSize);
|
||||
}
|
||||
|
||||
protected static bool TryParseAttribute(string name, string ns, string value, ServiceDocument document, string version)
|
||||
{
|
||||
if (document == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("document");
|
||||
}
|
||||
return document.TryParseAttribute(name, ns, value, version);
|
||||
}
|
||||
|
||||
protected static bool TryParseAttribute(string name, string ns, string value, ResourceCollectionInfo collection, string version)
|
||||
{
|
||||
if (collection == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("collection");
|
||||
}
|
||||
return collection.TryParseAttribute(name, ns, value, version);
|
||||
}
|
||||
|
||||
protected static bool TryParseAttribute(string name, string ns, string value, CategoriesDocument categories, string version)
|
||||
{
|
||||
if (categories == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("categories");
|
||||
}
|
||||
return categories.TryParseAttribute(name, ns, value, version);
|
||||
}
|
||||
|
||||
protected static bool TryParseAttribute(string name, string ns, string value, Workspace workspace, string version)
|
||||
{
|
||||
if (workspace == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workspace");
|
||||
}
|
||||
return workspace.TryParseAttribute(name, ns, value, version);
|
||||
}
|
||||
|
||||
protected static bool TryParseElement(XmlReader reader, ResourceCollectionInfo collection, string version)
|
||||
{
|
||||
if (collection == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("collection");
|
||||
}
|
||||
return collection.TryParseElement(reader, version);
|
||||
}
|
||||
|
||||
protected static bool TryParseElement(XmlReader reader, ServiceDocument document, string version)
|
||||
{
|
||||
if (document == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("document");
|
||||
}
|
||||
return document.TryParseElement(reader, version);
|
||||
}
|
||||
|
||||
protected static bool TryParseElement(XmlReader reader, Workspace workspace, string version)
|
||||
{
|
||||
if (workspace == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workspace");
|
||||
}
|
||||
return workspace.TryParseElement(reader, version);
|
||||
}
|
||||
|
||||
protected static bool TryParseElement(XmlReader reader, CategoriesDocument categories, string version)
|
||||
{
|
||||
if (categories == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("categories");
|
||||
}
|
||||
return categories.TryParseElement(reader, version);
|
||||
}
|
||||
|
||||
protected static void WriteAttributeExtensions(XmlWriter writer, ServiceDocument document, string version)
|
||||
{
|
||||
if (document == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("document");
|
||||
}
|
||||
document.WriteAttributeExtensions(writer, version);
|
||||
}
|
||||
|
||||
protected static void WriteAttributeExtensions(XmlWriter writer, Workspace workspace, string version)
|
||||
{
|
||||
if (workspace == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workspace");
|
||||
}
|
||||
workspace.WriteAttributeExtensions(writer, version);
|
||||
}
|
||||
|
||||
protected static void WriteAttributeExtensions(XmlWriter writer, ResourceCollectionInfo collection, string version)
|
||||
{
|
||||
if (collection == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("collection");
|
||||
}
|
||||
collection.WriteAttributeExtensions(writer, version);
|
||||
}
|
||||
|
||||
protected static void WriteAttributeExtensions(XmlWriter writer, CategoriesDocument categories, string version)
|
||||
{
|
||||
if (categories == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("categories");
|
||||
}
|
||||
categories.WriteAttributeExtensions(writer, version);
|
||||
}
|
||||
|
||||
protected static void WriteElementExtensions(XmlWriter writer, ServiceDocument document, string version)
|
||||
{
|
||||
if (document == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("document");
|
||||
}
|
||||
document.WriteElementExtensions(writer, version);
|
||||
}
|
||||
|
||||
protected static void WriteElementExtensions(XmlWriter writer, Workspace workspace, string version)
|
||||
{
|
||||
if (workspace == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workspace");
|
||||
}
|
||||
workspace.WriteElementExtensions(writer, version);
|
||||
}
|
||||
|
||||
protected static void WriteElementExtensions(XmlWriter writer, ResourceCollectionInfo collection, string version)
|
||||
{
|
||||
if (collection == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("collection");
|
||||
}
|
||||
collection.WriteElementExtensions(writer, version);
|
||||
}
|
||||
|
||||
protected static void WriteElementExtensions(XmlWriter writer, CategoriesDocument categories, string version)
|
||||
{
|
||||
if (categories == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("categories");
|
||||
}
|
||||
categories.WriteElementExtensions(writer, version);
|
||||
}
|
||||
|
||||
protected virtual ServiceDocument CreateDocumentInstance()
|
||||
{
|
||||
return new ServiceDocument();
|
||||
}
|
||||
|
||||
protected virtual void SetDocument(ServiceDocument document)
|
||||
{
|
||||
this.document = document;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user