#region License Information /* HeuristicLab * Copyright (C) 2002-2015 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 using System; namespace HeuristicLab.PluginInfrastructure { /// /// Abstract base implementation for the IApplication interface. /// [Serializable] public abstract class ApplicationBase : IApplication { /// /// Initializes a new instance of . /// protected ApplicationBase() { } private ApplicationAttribute ApplicationAttribute { get { object[] appAttributes = GetType().GetCustomAttributes(typeof(ApplicationAttribute), false); // exactly one attribute of the type ClassInfoAttribute must be given if (appAttributes.Length == 0) { throw new InvalidPluginException("ApplicationAttribute on type " + GetType() + " is missing."); } else if (appAttributes.Length > 1) { throw new InvalidPluginException("Found multiple ApplicationAttributes on type " + GetType()); } return (ApplicationAttribute)appAttributes[0]; } } #region IApplication Members /// /// Gets the name of the application. /// public string Name => ApplicationAttribute.Name; /// /// Gets the description of the application. /// public string Description => ApplicationAttribute.Description; /// /// Runs the application. /// public abstract void Run(ICommandLineArgument[] args); public virtual void OnCancel() { } public virtual void OnPause() { } public virtual void OnResume() { } #endregion } }