[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 {
|
---|
| 32 | Assembly,
|
---|
[2496] | 33 | NativeDll,
|
---|
[5] | 34 | Data,
|
---|
| 35 | License
|
---|
| 36 | };
|
---|
| 37 |
|
---|
[1189] | 38 | /// <summary>
|
---|
[2475] | 39 | /// PluginFileAttribute can be used to declare which files make up an plugin.
|
---|
| 40 | /// Multiple files can be associated to an plugin. Each file should be associated to only one plugin.
|
---|
[1189] | 41 | /// </summary>
|
---|
[2475] | 42 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
---|
[2504] | 43 | public sealed class PluginFileAttribute : System.Attribute {
|
---|
| 44 | private string fileName;
|
---|
[2] | 45 |
|
---|
[1189] | 46 | /// <summary>
|
---|
[2504] | 47 | /// Gets the file name of the plugin.
|
---|
[1189] | 48 | /// </summary>
|
---|
[2504] | 49 | public string FileName {
|
---|
| 50 | get { return fileName; }
|
---|
[2] | 51 | }
|
---|
| 52 |
|
---|
[2504] | 53 | private PluginFileType fileType = PluginFileType.Data;
|
---|
[2] | 54 |
|
---|
[1189] | 55 | /// <summary>
|
---|
[2504] | 56 | /// Gets the file type of the plugin file.
|
---|
[1189] | 57 | /// </summary>
|
---|
[2504] | 58 | public PluginFileType FileType {
|
---|
| 59 | get { return fileType; }
|
---|
[2] | 60 | }
|
---|
| 61 |
|
---|
[1189] | 62 | /// <summary>
|
---|
| 63 | /// Initializes a new instance of <see cref="PluginFileAttribute"/>.
|
---|
[2504] | 64 | /// <param name="fileName">Name of the file</param>
|
---|
| 65 | /// <param name="fileType">Type of the file (Assembly, NativeDll, Data, License)</param>
|
---|
[1189] | 66 | /// </summary>
|
---|
[2504] | 67 | public PluginFileAttribute(string fileName, PluginFileType fileType) {
|
---|
| 68 | if (string.IsNullOrEmpty(fileName)) throw new ArgumentException("File name is empty.", "fileName");
|
---|
| 69 | // NB: doesn't check if the file actually exists
|
---|
| 70 | this.fileName = fileName;
|
---|
| 71 | this.fileType = fileType;
|
---|
[2475] | 72 | }
|
---|
[2] | 73 | }
|
---|
| 74 | }
|
---|