#region License Information
/* HeuristicLab
* Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
namespace HeuristicLab.PluginInfrastructure {
///
/// Abstract base implementation of the IPlugin interface.
///
public abstract class PluginBase : IPlugin {
///
/// Initializes a new instance of .
///
protected PluginBase() { }
private PluginAttribute PluginAttribute {
get {
object[] pluginAttributes = this.GetType().GetCustomAttributes(typeof(PluginAttribute), false);
// exactly one attribute of the type PluginDescriptionAttribute must be given
if (pluginAttributes.Length == 0) {
throw new InvalidPluginException("PluginAttribute on type " + this.GetType() + " is missing.");
} else if (pluginAttributes.Length > 1) {
throw new InvalidPluginException("Found multiple PluginAttributes on type " + this.GetType());
}
return (PluginAttribute)pluginAttributes[0];
}
}
#region IPlugin Members
///
public string Name {
get {
return PluginAttribute.Name;
}
}
///
public virtual void OnLoad() { }
///
public virtual void OnUnload() { }
#endregion
}
}