2
// AddinSystemConfigurationReader.cs
7
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
9
// Permission is hereby granted, free of charge, to any person obtaining
10
// a copy of this software and associated documentation files (the
11
// "Software"), to deal in the Software without restriction, including
12
// without limitation the rights to use, copy, modify, merge, publish,
13
// distribute, sublicense, and/or sell copies of the Software, and to
14
// permit persons to whom the Software is furnished to do so, subject to
15
// the following conditions:
17
// The above copyright notice and this permission notice shall be
18
// included in all copies or substantial portions of the Software.
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
using System.Xml.Schema;
32
using System.Xml.Serialization;
34
using System.Collections;
35
using System.Globalization;
37
namespace Mono.Addins.Setup
39
internal class AddinSystemConfigurationReader : XmlSerializationReader
41
public object ReadRoot_AddinSystemConfiguration ()
43
Reader.MoveToContent();
44
if (Reader.LocalName != "AddinSystemConfiguration" || Reader.NamespaceURI != "")
45
throw CreateUnknownNodeException();
46
return ReadObject_AddinSystemConfiguration (true, true);
49
public Mono.Addins.Setup.AddinSystemConfiguration ReadObject_AddinSystemConfiguration (bool isNullable, bool checkType)
51
Mono.Addins.Setup.AddinSystemConfiguration ob = null;
52
if (isNullable && ReadNull()) return null;
56
System.Xml.XmlQualifiedName t = GetXsiType();
59
else if (t.Name != "AddinSystemConfiguration" || t.Namespace != "")
60
throw CreateUnknownTypeException(t);
63
ob = new Mono.Addins.Setup.AddinSystemConfiguration ();
65
Reader.MoveToElement();
67
while (Reader.MoveToNextAttribute())
69
if (IsXmlnsAttribute (Reader.Name)) {
76
Reader.MoveToElement();
77
if (Reader.IsEmptyElement) {
82
Reader.ReadStartElement();
83
Reader.MoveToContent();
85
bool b0=false, b1=false, b2=false, b3=false;
87
while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
89
if (Reader.NodeType == System.Xml.XmlNodeType.Element)
91
if (Reader.LocalName == "AddinPaths" && Reader.NamespaceURI == "" && !b3) {
92
if (((object)ob.@AddinPaths) == null)
93
throw CreateReadOnlyCollectionException ("System.Collections.Specialized.StringCollection");
94
if (Reader.IsEmptyElement) {
98
Reader.ReadStartElement();
99
Reader.MoveToContent();
101
while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
103
if (Reader.NodeType == System.Xml.XmlNodeType.Element)
105
if (Reader.LocalName == "Addin" && Reader.NamespaceURI == "") {
106
if (((object)ob.@AddinPaths) == null)
107
throw CreateReadOnlyCollectionException ("System.Collections.Specialized.StringCollection");
108
ob.@AddinPaths.Add (Reader.ReadElementString ());
111
else UnknownNode (null);
113
else UnknownNode (null);
115
Reader.MoveToContent();
121
else if (Reader.LocalName == "RepositoryIdCount" && Reader.NamespaceURI == "" && !b1) {
123
ob.@RepositoryIdCount = Int32.Parse (Reader.ReadElementString (), CultureInfo.InvariantCulture);
125
else if (Reader.LocalName == "DisabledAddins" && Reader.NamespaceURI == "" && !b2) {
126
if (((object)ob.@DisabledAddins) == null)
127
throw CreateReadOnlyCollectionException ("System.Collections.Specialized.StringCollection");
128
if (Reader.IsEmptyElement) {
132
Reader.ReadStartElement();
133
Reader.MoveToContent();
135
while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
137
if (Reader.NodeType == System.Xml.XmlNodeType.Element)
139
if (Reader.LocalName == "Addin" && Reader.NamespaceURI == "") {
140
if (((object)ob.@DisabledAddins) == null)
141
throw CreateReadOnlyCollectionException ("System.Collections.Specialized.StringCollection");
142
ob.@DisabledAddins.Add (Reader.ReadElementString ());
145
else UnknownNode (null);
147
else UnknownNode (null);
149
Reader.MoveToContent();
155
else if (Reader.LocalName == "Repositories" && Reader.NamespaceURI == "" && !b0) {
156
if (((object)ob.@Repositories) == null)
157
throw CreateReadOnlyCollectionException ("System.Collections.ArrayList");
158
if (Reader.IsEmptyElement) {
162
Reader.ReadStartElement();
163
Reader.MoveToContent();
165
while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
167
if (Reader.NodeType == System.Xml.XmlNodeType.Element)
169
if (Reader.LocalName == "Repository" && Reader.NamespaceURI == "") {
170
if (((object)ob.@Repositories) == null)
171
throw CreateReadOnlyCollectionException ("System.Collections.ArrayList");
172
ob.@Repositories.Add (ReadObject_RepositoryRecord (false, true));
175
else UnknownNode (null);
177
else UnknownNode (null);
179
Reader.MoveToContent();
192
Reader.MoveToContent();
200
public Mono.Addins.Setup.RepositoryRecord ReadObject_RepositoryRecord (bool isNullable, bool checkType)
202
Mono.Addins.Setup.RepositoryRecord ob = null;
203
if (isNullable && ReadNull()) return null;
207
System.Xml.XmlQualifiedName t = GetXsiType();
210
else if (t.Name != "RepositoryRecord" || t.Namespace != "")
211
throw CreateUnknownTypeException(t);
214
ob = new Mono.Addins.Setup.RepositoryRecord ();
216
Reader.MoveToElement();
218
while (Reader.MoveToNextAttribute())
220
if (Reader.LocalName == "id" && Reader.NamespaceURI == "") {
221
ob.@Id = Reader.Value;
223
else if (IsXmlnsAttribute (Reader.Name)) {
230
Reader.MoveToElement();
231
if (Reader.IsEmptyElement) {
236
Reader.ReadStartElement();
237
Reader.MoveToContent();
239
bool b7=false, b8=false, b9=false, b10=false, b11=false;
241
while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
243
if (Reader.NodeType == System.Xml.XmlNodeType.Element)
245
if (Reader.LocalName == "File" && Reader.NamespaceURI == "" && !b8) {
247
ob.@File = Reader.ReadElementString ();
249
else if (Reader.LocalName == "IsReference" && Reader.NamespaceURI == "" && !b7) {
251
ob.@IsReference = XmlConvert.ToBoolean (Reader.ReadElementString ());
253
else if (Reader.LocalName == "Name" && Reader.NamespaceURI == "" && !b10) {
255
ob.@Name = Reader.ReadElementString ();
257
else if (Reader.LocalName == "Url" && Reader.NamespaceURI == "" && !b9) {
259
ob.@Url = Reader.ReadElementString ();
261
else if (Reader.LocalName == "LastModified" && Reader.NamespaceURI == "" && !b11) {
263
ob.@LastModified = XmlConvert.ToDateTime (Reader.ReadElementString ());
272
Reader.MoveToContent();
280
protected override void InitCallbacks ()
284
protected override void InitIDs ()
290
internal class AddinSystemConfigurationWriter : XmlSerializationWriter
292
const string xmlNamespace = "http://www.w3.org/2000/xmlns/";
293
public void WriteRoot_AddinSystemConfiguration (object o)
295
WriteStartDocument ();
296
Mono.Addins.Setup.AddinSystemConfiguration ob = (Mono.Addins.Setup.AddinSystemConfiguration) o;
298
WriteObject_AddinSystemConfiguration (ob, "AddinSystemConfiguration", "", true, false, true);
301
void WriteObject_AddinSystemConfiguration (Mono.Addins.Setup.AddinSystemConfiguration ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
303
if (((object)ob) == null)
306
WriteNullTagLiteral(element, namesp);
310
System.Type type = ob.GetType ();
311
if (type == typeof(Mono.Addins.Setup.AddinSystemConfiguration))
314
throw CreateUnknownTypeException (ob);
317
if (writeWrappingElem) {
318
WriteStartElement (element, namesp, ob);
321
if (needType) WriteXsiType("AddinSystemConfiguration", "");
323
if (ob.@Repositories != null) {
324
WriteStartElement ("Repositories", "", ob.@Repositories);
325
for (int n12 = 0; n12 < ob.@Repositories.Count; n12++) {
326
WriteObject_RepositoryRecord (((Mono.Addins.Setup.RepositoryRecord) ob.@Repositories[n12]), "Repository", "", false, false, true);
328
WriteEndElement (ob.@Repositories);
330
WriteElementString ("RepositoryIdCount", "", ob.@RepositoryIdCount.ToString(CultureInfo.InvariantCulture));
331
if (ob.@DisabledAddins != null) {
332
WriteStartElement ("DisabledAddins", "", ob.@DisabledAddins);
333
for (int n13 = 0; n13 < ob.@DisabledAddins.Count; n13++) {
334
WriteElementString ("Addin", "", ob.@DisabledAddins[n13]);
336
WriteEndElement (ob.@DisabledAddins);
338
if (ob.@AddinPaths != null) {
339
WriteStartElement ("AddinPaths", "", ob.@AddinPaths);
340
for (int n14 = 0; n14 < ob.@AddinPaths.Count; n14++) {
341
WriteElementString ("Addin", "", ob.@AddinPaths[n14]);
343
WriteEndElement (ob.@AddinPaths);
345
if (writeWrappingElem) WriteEndElement (ob);
348
void WriteObject_RepositoryRecord (Mono.Addins.Setup.RepositoryRecord ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
350
if (((object)ob) == null)
353
WriteNullTagLiteral(element, namesp);
357
System.Type type = ob.GetType ();
358
if (type == typeof(Mono.Addins.Setup.RepositoryRecord))
361
throw CreateUnknownTypeException (ob);
364
if (writeWrappingElem) {
365
WriteStartElement (element, namesp, ob);
368
if (needType) WriteXsiType("RepositoryRecord", "");
370
WriteAttribute ("id", "", ob.@Id);
372
WriteElementString ("IsReference", "", (ob.@IsReference?"true":"false"));
373
WriteElementString ("File", "", ob.@File);
374
WriteElementString ("Url", "", ob.@Url);
375
WriteElementString ("Name", "", ob.@Name);
376
WriteElementString ("LastModified", "", ob.@LastModified.ToString("yyyy-MM-ddTHH:mm:ss.fffffffzzz", CultureInfo.InvariantCulture));
377
if (writeWrappingElem) WriteEndElement (ob);
380
protected override void InitCallbacks ()