Imported Upstream version 5.10.0.47

Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-24 17:04:36 +00:00
parent 88ff76fe28
commit e46a49ecf1
5927 changed files with 226314 additions and 129848 deletions

View File

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26906.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.ServiceModel.Syndication", "src\System.ServiceModel.Syndication.csproj", "{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.ServiceModel.Syndication.Tests", "tests\System.ServiceModel.Syndication.Tests.csproj", "{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
netstandard-Debug|Any CPU = netstandard-Debug|Any CPU
netstandard-Release|Any CPU = netstandard-Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}.netstandard-Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}.netstandard-Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}.netstandard-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}.netstandard-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}.netstandard-Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}.netstandard-Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}.netstandard-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}.netstandard-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C509160C-D427-4B6F-A515-169B6BB2B210}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyKey>Open</AssemblyKey>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<ProjectReference Include="..\ref\System.ServiceModel.Syndication.csproj">
<SupportedFramework>net461;netcoreapp2.0;$(AllXamarinFrameworks)</SupportedFramework>
</ProjectReference>
<ProjectReference Include="..\src\System.ServiceModel.Syndication.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netfx;
netstandard;
</BuildConfigurations>
</PropertyGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{E81F4C7C-2000-4449-BEE6-B2E84DE218F7}</ProjectGuid>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<Compile Include="System.ServiceModel.Syndication.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<Compile Include="System.ServiceModel.Syndication.netfx.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Xml" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netstandard;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1 @@
5534250e892af7b6d8156f5b934427eb38bf7d79

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<AssemblyName>System.ServiceModel.Syndication</AssemblyName>
<ProjectGuid>{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}</ProjectGuid>
<NoWarn>$(NoWarn);1634;1691;649</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="$(MsBuildThisFileDirectory)\**\*.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,44 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.ServiceModel.Channels
{
using System.Threading;
using System.Globalization;
using System.ServiceModel;
internal class UriGenerator
{
private long _id;
private string _prefix;
public UriGenerator()
: this("uuid")
{
}
public UriGenerator(string scheme)
: this(scheme, ";")
{
}
public UriGenerator(string scheme, string delimiter)
{
if (scheme == null)
throw new ArgumentException("scheme");
//throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("scheme"));
if (scheme.Length == 0)
throw new ArgumentException(string.Format(SR.UriGeneratorSchemeMustNotBeEmpty, "scheme"));
_prefix = string.Concat(scheme, ":", Guid.NewGuid().ToString(), delimiter, "id=");
}
public string Next()
{
long nextId = Interlocked.Increment(ref _id);
return _prefix + nextId.ToString(CultureInfo.InvariantCulture);
}
}
}

View File

@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.ServiceModel.Syndication
{
internal 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";
}
}

View File

@@ -0,0 +1,53 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.ServiceModel.Syndication
{
public 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";
public const string IconTag = "icon";
}
}

View File

@@ -0,0 +1,168 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*
* Some diagnostic lines have been commented
*
* */
namespace System.ServiceModel.Syndication
{
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
[XmlRoot(ElementName = Atom10Constants.EntryTag, Namespace = Atom10Constants.Atom10Namespace)]
public class Atom10ItemFormatter : SyndicationItemFormatter
{
private Atom10FeedFormatter _feedSerializer;
private Type _itemType;
private bool _preserveAttributeExtensions;
private bool _preserveElementExtensions;
public Atom10ItemFormatter()
: this(typeof(SyndicationItem))
{
}
public Atom10ItemFormatter(Type itemTypeToCreate)
: base()
{
if (itemTypeToCreate == null)
{
throw new ArgumentNullException(nameof(itemTypeToCreate));
}
if (!typeof(SyndicationItem).IsAssignableFrom(itemTypeToCreate))
{
throw new ArgumentException(string.Format(SR.InvalidObjectTypePassed, nameof(itemTypeToCreate), nameof(SyndicationItem)));
}
_feedSerializer = new Atom10FeedFormatter();
_feedSerializer.PreserveAttributeExtensions = _preserveAttributeExtensions = true;
_feedSerializer.PreserveElementExtensions = _preserveElementExtensions = true;
_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
_feedSerializer = new Atom10FeedFormatter();
_feedSerializer.PreserveAttributeExtensions = _preserveAttributeExtensions = true;
_feedSerializer.PreserveElementExtensions = _preserveElementExtensions = true;
_itemType = itemToWrite.GetType();
}
public bool PreserveAttributeExtensions
{
get { return _preserveAttributeExtensions; }
set
{
_preserveAttributeExtensions = value;
_feedSerializer.PreserveAttributeExtensions = value;
}
}
public bool PreserveElementExtensions
{
get { return _preserveElementExtensions; }
set
{
_preserveElementExtensions = value;
_feedSerializer.PreserveElementExtensions = value;
}
}
public override string Version
{
get { return SyndicationVersions.Atom10; }
}
protected Type ItemType
{
get
{
return _itemType;
}
}
public override bool CanRead(XmlReader reader)
{
if (reader == null)
{
throw new ArgumentNullException(nameof(reader));
}
return reader.IsStartElement(Atom10Constants.EntryTag, Atom10Constants.Atom10Namespace);
}
public override Task ReadFromAsync(XmlReader reader)
{
if (!CanRead(reader))
{
throw new XmlException(string.Format(SR.UnknownItemXml, reader.LocalName, reader.NamespaceURI));
}
return ReadItemAsync(reader);
}
public override async Task WriteToAsync(XmlWriter writer)
{
if (writer == null)
{
throw new ArgumentNullException(nameof(writer));
}
writer = XmlWriterWrapper.CreateFromWriter(writer);
await writer.WriteStartElementAsync(Atom10Constants.EntryTag, Atom10Constants.Atom10Namespace);
await WriteItemAsync(writer);
await writer.WriteEndElementAsync();
}
protected override SyndicationItem CreateItemInstance()
{
return SyndicationItemFormatter.CreateItemInstance(_itemType);
}
private Task ReadItemAsync(XmlReader reader)
{
SetItem(CreateItemInstance());
return _feedSerializer.ReadItemFromAsync(XmlReaderWrapper.CreateFromReader(XmlDictionaryReader.CreateDictionaryReader(reader)), this.Item);
}
private Task WriteItemAsync(XmlWriter writer)
{
if (this.Item == null)
{
throw new InvalidOperationException(SR.ItemFormatterDoesNotHaveItem);
}
XmlDictionaryWriter w = XmlDictionaryWriter.CreateDictionaryWriter(writer);
return _feedSerializer.WriteItemContentsAsync(w, this.Item);
}
}
[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();
}
}
}

View File

@@ -0,0 +1,213 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.ServiceModel.Syndication
{
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
[XmlRoot(ElementName = App10Constants.Categories, Namespace = App10Constants.Namespace)]
public class AtomPub10CategoriesDocumentFormatter : CategoriesDocumentFormatter
{
private Type _inlineDocumentType;
private int _maxExtensionSize;
private bool _preserveAttributeExtensions;
private bool _preserveElementExtensions;
private Type _referencedDocumentType;
public AtomPub10CategoriesDocumentFormatter()
: this(typeof(InlineCategoriesDocument), typeof(ReferencedCategoriesDocument))
{
}
public AtomPub10CategoriesDocumentFormatter(Type inlineDocumentType, Type referencedDocumentType)
: base()
{
if (inlineDocumentType == null)
{
throw new ArgumentNullException(nameof(inlineDocumentType));
}
if (!typeof(InlineCategoriesDocument).IsAssignableFrom(inlineDocumentType))
{
throw new ArgumentException(string.Format(SR.InvalidObjectTypePassed, nameof(inlineDocumentType), nameof(InlineCategoriesDocument)));
}
if (referencedDocumentType == null)
{
throw new ArgumentNullException(nameof(referencedDocumentType));
}
if (!typeof(ReferencedCategoriesDocument).IsAssignableFrom(referencedDocumentType))
{
throw new ArgumentException(string.Format(SR.InvalidObjectTypePassed, nameof(referencedDocumentType), nameof(ReferencedCategoriesDocument)));
}
_maxExtensionSize = int.MaxValue;
_preserveAttributeExtensions = true;
_preserveElementExtensions = true;
_inlineDocumentType = inlineDocumentType;
_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
_maxExtensionSize = int.MaxValue;
_preserveAttributeExtensions = true;
_preserveElementExtensions = true;
if (documentToWrite.IsInline)
{
_inlineDocumentType = documentToWrite.GetType();
_referencedDocumentType = typeof(ReferencedCategoriesDocument);
}
else
{
_referencedDocumentType = documentToWrite.GetType();
_inlineDocumentType = typeof(InlineCategoriesDocument);
}
}
public override string Version
{
get { return App10Constants.Namespace; }
}
public override Task<bool> CanReadAsync(XmlReader reader)
{
if (reader == null)
{
throw new ArgumentNullException(nameof(reader));
}
XmlReaderWrapper wrappedReader = XmlReaderWrapper.CreateFromReader(reader);
return wrappedReader.IsStartElementAsync(App10Constants.Categories, App10Constants.Namespace);
}
private Task ReadXmlAsync(XmlReaderWrapper reader)
{
if (reader == null)
{
throw new ArgumentNullException(nameof(reader));
}
return ReadDocumentAsync(reader);
}
private Task WriteXmlAsync(XmlWriter writer)
{
if (writer == null)
{
throw new ArgumentNullException(nameof(writer));
}
if (this.Document == null)
{
throw new InvalidOperationException(SR.DocumentFormatterDoesNotHaveDocument);
}
return WriteDocumentAsync(writer);
}
public override async Task ReadFromAsync(XmlReader reader)
{
if (reader == null)
{
throw new ArgumentNullException(nameof(reader));
}
if (!await CanReadAsync(reader))
{
throw new XmlException(string.Format(SR.UnknownDocumentXml, reader.LocalName, reader.NamespaceURI));
}
await ReadDocumentAsync(XmlReaderWrapper.CreateFromReader(reader));
}
public override async Task WriteTo(XmlWriter writer)
{
if (writer == null)
{
throw new ArgumentNullException(nameof(writer));
}
if (this.Document == null)
{
throw new InvalidOperationException(SR.DocumentFormatterDoesNotHaveDocument);
}
writer.WriteStartElement(App10Constants.Prefix, App10Constants.Categories, App10Constants.Namespace);
await WriteDocumentAsync(writer);
writer.WriteEndElement();
}
protected override InlineCategoriesDocument CreateInlineCategoriesDocument()
{
if (_inlineDocumentType == typeof(InlineCategoriesDocument))
{
return new InlineCategoriesDocument();
}
else
{
return (InlineCategoriesDocument)Activator.CreateInstance(_inlineDocumentType);
}
}
protected override ReferencedCategoriesDocument CreateReferencedCategoriesDocument()
{
if (_referencedDocumentType == typeof(ReferencedCategoriesDocument))
{
return new ReferencedCategoriesDocument();
}
else
{
return (ReferencedCategoriesDocument)Activator.CreateInstance(_referencedDocumentType);
}
}
private async Task ReadDocumentAsync(XmlReaderWrapper reader)
{
try
{
await SyndicationFeedFormatter.MoveToStartElementAsync(reader);
SetDocument(await AtomPub10ServiceDocumentFormatter.ReadCategories(reader, null,
delegate ()
{
return this.CreateInlineCategoriesDocument();
},
delegate ()
{
return this.CreateReferencedCategoriesDocument();
},
this.Version,
_preserveElementExtensions,
_preserveAttributeExtensions,
_maxExtensionSize));
}
catch (FormatException e)
{
throw new XmlException(FeedUtils.AddLineInfo(reader, SR.ErrorParsingDocument), e);
}
catch (ArgumentException e)
{
throw new XmlException(FeedUtils.AddLineInfo(reader, SR.ErrorParsingDocument), e);
}
}
private Task WriteDocumentAsync(XmlWriter writer)
{
// declare the atom10 namespace upfront for compactness
writer.WriteAttributeString(Atom10Constants.Atom10Prefix, Atom10FeedFormatter.XmlNsNs, Atom10Constants.Atom10Namespace);
return AtomPub10ServiceDocumentFormatter.WriteCategoriesInnerXml(writer, this.Document, null, this.Version);
}
}
}

View File

@@ -0,0 +1,119 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.ServiceModel.Syndication
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Xml;
public abstract class CategoriesDocument : IExtensibleSyndicationObject
{
private Uri _baseUri;
private ExtensibleSyndicationObject _extensions = new ExtensibleSyndicationObject();
private string _language;
internal CategoriesDocument()
{
}
public Dictionary<XmlQualifiedName, string> AttributeExtensions
{
get
{
return _extensions.AttributeExtensions;
}
}
public Uri BaseUri
{
get { return _baseUri; }
set { _baseUri = value; }
}
public SyndicationElementExtensionCollection ElementExtensions
{
get
{
return _extensions.ElementExtensions;
}
}
public string Language
{
get { return _language; }
set { _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 async Task<CategoriesDocument> LoadAsync(XmlReader reader)
{
AtomPub10CategoriesDocumentFormatter formatter = new AtomPub10CategoriesDocumentFormatter();
await formatter.ReadFromAsync(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 Task WriteAttributeExtensionsAsync(XmlWriter writer, string version)
{
return _extensions.WriteAttributeExtensionsAsync(writer);
}
protected internal virtual Task WriteElementExtensionsAsync(XmlWriter writer, string version)
{
return _extensions.WriteElementExtensionsAsync(writer);
}
internal void LoadElementExtensions(XmlReaderWrapper readerOverUnparsedExtensions, int maxExtensionSize)
{
_extensions.LoadElementExtensions(readerOverUnparsedExtensions, maxExtensionSize);
}
internal void LoadElementExtensions(XmlBuffer buffer)
{
_extensions.LoadElementExtensions(buffer);
}
}
}

View File

@@ -0,0 +1,56 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.ServiceModel.Syndication
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using System.Xml;
public abstract class CategoriesDocumentFormatter
{
private CategoriesDocument _document;
protected CategoriesDocumentFormatter()
{
}
protected CategoriesDocumentFormatter(CategoriesDocument documentToWrite)
{
if (documentToWrite == null)
{
throw new ArgumentNullException(nameof(documentToWrite));
}
_document = documentToWrite;
}
public CategoriesDocument Document
{
get { return _document; }
}
public abstract string Version
{ get; }
public abstract Task<bool> CanReadAsync(XmlReader reader);
public abstract Task ReadFromAsync(XmlReader reader);
public abstract Task WriteTo(XmlWriter writer);
protected virtual InlineCategoriesDocument CreateInlineCategoriesDocument()
{
return new InlineCategoriesDocument();
}
protected virtual ReferencedCategoriesDocument CreateReferencedCategoriesDocument()
{
return new ReferencedCategoriesDocument();
}
protected virtual void SetDocument(CategoriesDocument document)
{
_document = document;
}
}
}

View File

@@ -0,0 +1,142 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.ServiceModel.Syndication
{
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Xml;
using System.Threading.Tasks;
// NOTE: This class implements Clone so if you add any members, please update the copy ctor
internal struct ExtensibleSyndicationObject : IExtensibleSyndicationObject
{
private Dictionary<XmlQualifiedName, string> _attributeExtensions;
private SyndicationElementExtensionCollection _elementExtensions;
private ExtensibleSyndicationObject(ExtensibleSyndicationObject source)
{
if (source._attributeExtensions != null)
{
_attributeExtensions = new Dictionary<XmlQualifiedName, string>();
foreach (XmlQualifiedName key in source._attributeExtensions.Keys)
{
_attributeExtensions.Add(key, source._attributeExtensions[key]);
}
}
else
{
_attributeExtensions = null;
}
if (source._elementExtensions != null)
{
_elementExtensions = new SyndicationElementExtensionCollection(source._elementExtensions);
}
else
{
_elementExtensions = null;
}
}
public Dictionary<XmlQualifiedName, string> AttributeExtensions
{
get
{
if (_attributeExtensions == null)
{
_attributeExtensions = new Dictionary<XmlQualifiedName, string>();
}
return _attributeExtensions;
}
}
public SyndicationElementExtensionCollection ElementExtensions
{
get
{
if (_elementExtensions == null)
{
_elementExtensions = new SyndicationElementExtensionCollection();
}
return _elementExtensions;
}
}
private 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 new ArgumentNullException(nameof(readerOverUnparsedExtensions));
}
if (maxExtensionSize < 0)
{
throw new ArgumentOutOfRangeException(nameof(maxExtensionSize));
}
XmlDictionaryReader r = XmlDictionaryReader.CreateDictionaryReader(readerOverUnparsedExtensions);
_elementExtensions = new SyndicationElementExtensionCollection(CreateXmlBuffer(r, maxExtensionSize));
}
internal void LoadElementExtensions(XmlBuffer buffer)
{
_elementExtensions = new SyndicationElementExtensionCollection(buffer);
}
internal async Task WriteAttributeExtensionsAsync(XmlWriter writer)
{
if (writer == null)
{
throw new ArgumentNullException(nameof(writer));
}
writer = XmlWriterWrapper.CreateFromWriter(writer);
if (_attributeExtensions != null)
{
foreach (XmlQualifiedName qname in _attributeExtensions.Keys)
{
string value = _attributeExtensions[qname];
await writer.WriteAttributeStringAsync(qname.Name, qname.Namespace, value);
}
}
}
internal async Task WriteElementExtensionsAsync(XmlWriter writer)
{
if (writer == null)
{
throw new ArgumentNullException(nameof(writer));
}
if (_elementExtensions != null)
{
await _elementExtensions.WriteToAsync(writer);
}
}
public ExtensibleSyndicationObject Clone()
{
return new ExtensibleSyndicationObject(this);
}
}
}

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