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.
30
using System.Collections;
31
using System.Collections.Specialized;
33
using System.Xml.Serialization;
34
using Mono.Addins.Serialization;
36
namespace Mono.Addins.Description
38
[XmlType ("AddinReference")]
39
public class AddinDependency: Dependency
44
public AddinDependency ()
48
public AddinDependency (string fullId)
50
Addin.GetIdParts (fullId, out id, out version);
54
public AddinDependency (string id, string version)
57
this.version = version;
60
internal AddinDependency (XmlElement elem): base (elem)
62
id = elem.GetAttribute ("id");
63
version = elem.GetAttribute ("version");
66
internal override void Verify (string location, StringCollection errors)
68
VerifyNotEmpty (location + "Dependencies/Addin/", errors, "id", AddinId);
69
VerifyNotEmpty (location + "Dependencies/Addin/", errors, "version", Version);
72
internal override void SaveXml (XmlElement parent)
74
CreateElement (parent, "Addin");
75
Element.SetAttribute ("id", AddinId);
76
Element.SetAttribute ("version", Version);
79
public string FullAddinId {
81
AddinDescription desc = ParentAddinDescription;
83
return Addin.GetFullId (null, AddinId, Version);
85
return Addin.GetFullId (desc.Namespace, AddinId, Version);
89
public string AddinId {
90
get { return id != null ? id : string.Empty; }
94
public string Version {
95
get { return version != null ? version : string.Empty; }
96
set { version = value; }
99
public override string Name {
100
get { return AddinId + " v" + version; }
103
internal override bool CheckInstalled ()
105
Addin[] addins = AddinManager.Registry.GetAddins ();
106
foreach (Addin addin in addins) {
107
if (addin.Id == id && addin.SupportsVersion (version)) {
114
internal override void Write (BinaryXmlWriter writer)
117
writer.WriteValue ("id", id);
118
writer.WriteValue ("version", version);
121
internal override void Read (BinaryXmlReader reader)
124
id = reader.ReadStringValue ("id");
125
version = reader.ReadStringValue ("version");