Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.PluginInfrastructure/PluginInfo.cs @ 2347

Last change on this file since 2347 was 1189, checked in by vdorfer, 16 years ago

Created parts of the API documentation for HeuristicLab.PluginInfrastructure namespace (#331)

File size: 4.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Text;
25
26namespace HeuristicLab.PluginInfrastructure {
27  /// <summary>
28  /// Holds information of loaded plugins that is needed for plugin management.
29  /// Used to represent plugins in AppDomains without loading the plugin assemblies.
30  /// </summary>
31  [Serializable]
32  public class PluginInfo {
33    private string name;
34    /// <summary>
35    /// Gets or sets the name of the plugin.
36    /// </summary>
37    public string Name {
38      get { return name; }
39      set { name = value; }
40    }
41    private Version version;
42    /// <summary>
43    /// Gets or sets the version of the plugin.
44    /// </summary>
45    public Version Version {
46      get { return version; }
47      set { version = value; }
48    }
49    private DateTime buildDate;
50    /// <summary>
51    /// Gets or sets the build date of the plugin.
52    /// </summary>
53    public DateTime BuildDate {
54      get { return buildDate; }
55      set { buildDate = value; }
56    }
57    private List<string> files = new List<string>();
58    /// <summary>
59    /// Gets the names of all files that belong to this plugin.
60    /// These files are deleted when the plugin is removed or updated.
61    /// </summary>
62    public List<string> Files {
63      get { return files; }
64    }
65
66    private List<PluginInfo> dependencies = new List<PluginInfo>();
67    /// <summary>
68    /// Gets all dependencies of the plugin.
69    /// </summary>
70    public List<PluginInfo> Dependencies {
71      get { return dependencies; }
72    }
73    private List<string> assemblies = new List<string>();
74    /// <summary>
75    /// Gets the names of the assemblies that belong to this plugin.
76    /// </summary>
77    public List<string> Assemblies {
78      get { return assemblies; }
79      set { assemblies = value; }
80    }
81    private string message;
82    /// <summary>
83    /// Gets or sets the message.
84    /// </summary>
85    public string Message {
86      get { return message; }
87      set { message = value; }
88    }
89    /// <summary>
90    /// Gets the string representation of the plugin.
91    /// </summary>
92    /// <returns>The name of the plugin.</returns>
93    public override string ToString() {
94      return Name;
95    }
96   
97    // equals and hashcode have to be implemented because we want to compare PluginDescriptions from
98    // different AppDomains and serialization destroys reference equality
99    /// <summary>
100    /// Checks whether the given object is equal to the current plugin.
101    /// </summary>
102    /// <param name="obj">The object to compare.</param>
103    /// <returns><c>true</c> if it is equal, <c>false</c> otherwise.</returns>
104    public override bool Equals(object obj) {
105      if(!(obj is PluginInfo))
106        return false;
107      PluginInfo other = (PluginInfo)obj;
108
109      return other.Name == this.Name && other.Version == this.Version;
110    }
111    /// <summary>
112    /// Gets the hash code of the current plugin.
113    /// </summary>
114    /// <returns>The hash code of the plugin.</returns>
115    public override int GetHashCode() {
116      if(version != null) {
117        return name.GetHashCode() + version.GetHashCode();
118      } else return name.GetHashCode();
119    }
120  }
121}
Note: See TracBrowser for help on using the repository browser.