1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.Collections.Generic;
6
using System.Collections.ObjectModel;
9
namespace ICSharpCode.Core
12
/// Stores information about the manifest of an AddIn.
14
public class AddInManifest
16
List<AddInReference> dependencies = new List<AddInReference>();
17
List<AddInReference> conflicts = new List<AddInReference>();
18
Dictionary<string, Version> identities = new Dictionary<string, Version>();
19
Version primaryVersion;
20
string primaryIdentity;
22
public string PrimaryIdentity {
24
return primaryIdentity;
28
public Version PrimaryVersion {
30
return primaryVersion;
34
public Dictionary<string, Version> Identities {
40
public ReadOnlyCollection<AddInReference> Dependencies {
42
return dependencies.AsReadOnly();
46
public ReadOnlyCollection<AddInReference> Conflicts {
48
return conflicts.AsReadOnly();
52
void AddIdentity(string name, string version, string hintPath)
55
throw new AddInLoadException("Identity needs a name");
56
foreach (char c in name) {
57
if (!char.IsLetterOrDigit(c) && c != '.' && c != '_') {
58
throw new AddInLoadException("Identity name contains invalid character: '" + c + "'");
61
Version v = AddInReference.ParseVersion(version, hintPath);
62
if (primaryVersion == null) {
65
if (primaryIdentity == null) {
66
primaryIdentity = name;
68
identities.Add(name, v);
71
public void ReadManifestSection(XmlReader reader, string hintPath)
73
if (reader.AttributeCount != 0) {
74
throw new AddInLoadException("Manifest node cannot have attributes.");
76
if (reader.IsEmptyElement) {
77
throw new AddInLoadException("Manifest node cannot be empty.");
79
while (reader.Read()) {
80
switch (reader.NodeType) {
81
case XmlNodeType.EndElement:
82
if (reader.LocalName == "Manifest") {
86
case XmlNodeType.Element:
87
string nodeName = reader.LocalName;
88
Properties properties = Properties.ReadFromAttributes(reader);
91
AddIdentity(properties["name"], properties["version"], hintPath);
94
dependencies.Add(AddInReference.Create(properties, hintPath));
97
conflicts.Add(AddInReference.Create(properties, hintPath));
100
throw new AddInLoadException("Unknown node in Manifest section:" + nodeName);