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