[2] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[11170] | 3 | * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[2] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 |
|
---|
| 24 | namespace HeuristicLab.PluginInfrastructure {
|
---|
[1189] | 25 | /// <summary>
|
---|
| 26 | /// Enumerator of available file types for a plugin.
|
---|
| 27 | /// </summary>
|
---|
[5] | 28 | public enum PluginFileType {
|
---|
[3092] | 29 | /// <summary>
|
---|
| 30 | /// CLR assembly files are loaded by the plugin infrastructure.
|
---|
| 31 | /// </summary>
|
---|
[5] | 32 | Assembly,
|
---|
[3092] | 33 | /// <summary>
|
---|
| 34 | /// Native DLL files are ignored by the plugin infrastructure.
|
---|
| 35 | /// </summary>
|
---|
[2496] | 36 | NativeDll,
|
---|
[3092] | 37 | /// <summary>
|
---|
| 38 | /// Data files are any kind of support file for your plugin.
|
---|
| 39 | /// </summary>
|
---|
[5] | 40 | Data,
|
---|
[3092] | 41 | /// <summary>
|
---|
| 42 | /// License files contain the license text of the plugin (ASCII encoding).
|
---|
| 43 | /// </summary>
|
---|
[5] | 44 | License
|
---|
| 45 | };
|
---|
| 46 |
|
---|
[1189] | 47 | /// <summary>
|
---|
[2475] | 48 | /// PluginFileAttribute can be used to declare which files make up an plugin.
|
---|
| 49 | /// Multiple files can be associated to an plugin. Each file should be associated to only one plugin.
|
---|
[1189] | 50 | /// </summary>
|
---|
[2475] | 51 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
---|
[2504] | 52 | public sealed class PluginFileAttribute : System.Attribute {
|
---|
| 53 | private string fileName;
|
---|
[2] | 54 |
|
---|
[1189] | 55 | /// <summary>
|
---|
[2504] | 56 | /// Gets the file name of the plugin.
|
---|
[1189] | 57 | /// </summary>
|
---|
[2504] | 58 | public string FileName {
|
---|
| 59 | get { return fileName; }
|
---|
[2] | 60 | }
|
---|
| 61 |
|
---|
[2504] | 62 | private PluginFileType fileType = PluginFileType.Data;
|
---|
[2] | 63 |
|
---|
[1189] | 64 | /// <summary>
|
---|
[2504] | 65 | /// Gets the file type of the plugin file.
|
---|
[1189] | 66 | /// </summary>
|
---|
[2504] | 67 | public PluginFileType FileType {
|
---|
| 68 | get { return fileType; }
|
---|
[2] | 69 | }
|
---|
| 70 |
|
---|
[1189] | 71 | /// <summary>
|
---|
| 72 | /// Initializes a new instance of <see cref="PluginFileAttribute"/>.
|
---|
[2504] | 73 | /// <param name="fileName">Name of the file</param>
|
---|
| 74 | /// <param name="fileType">Type of the file (Assembly, NativeDll, Data, License)</param>
|
---|
[1189] | 75 | /// </summary>
|
---|
[2504] | 76 | public PluginFileAttribute(string fileName, PluginFileType fileType) {
|
---|
| 77 | if (string.IsNullOrEmpty(fileName)) throw new ArgumentException("File name is empty.", "fileName");
|
---|
| 78 | // NB: doesn't check if the file actually exists
|
---|
| 79 | this.fileName = fileName;
|
---|
| 80 | this.fileType = fileType;
|
---|
[2475] | 81 | }
|
---|
[2] | 82 | }
|
---|
| 83 | }
|
---|