-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
ServiceDocument.cs
101 lines (81 loc) · 3.19 KB
/
ServiceDocument.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Xml;
namespace System.ServiceModel.Syndication
{
public class ServiceDocument : IExtensibleSyndicationObject
{
private ExtensibleSyndicationObject _extensions;
private Collection<Workspace> _workspaces;
public ServiceDocument() : this(null)
{
}
public ServiceDocument(IEnumerable<Workspace> workspaces)
{
if (workspaces != null)
{
_workspaces = new NullNotAllowedCollection<Workspace>();
foreach (Workspace workspace in workspaces)
{
_workspaces.Add(workspace);
}
}
}
public Dictionary<XmlQualifiedName, string> AttributeExtensions => _extensions.AttributeExtensions;
public Uri BaseUri { get; set; }
public SyndicationElementExtensionCollection ElementExtensions => _extensions.ElementExtensions;
public string Language { get; set; }
public Collection<Workspace> Workspaces
{
get => _workspaces ??= new NullNotAllowedCollection<Workspace>();
}
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)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)
{
_extensions.WriteAttributeExtensions(writer);
}
protected internal virtual void WriteElementExtensions(XmlWriter writer, string version)
{
_extensions.WriteElementExtensions(writer);
}
internal void LoadElementExtensions(XmlReader readerOverUnparsedExtensions, int maxExtensionSize)
{
_extensions.LoadElementExtensions(readerOverUnparsedExtensions, maxExtensionSize);
}
internal void LoadElementExtensions(XmlBuffer buffer)
{
_extensions.LoadElementExtensions(buffer);
}
}
}