Free cookie consent management tool by TermsFeed Policy Generator

source: branches/gteufl/HeuristicLab.PluginInfrastructure/3.3/Attributes/PluginFileAttribute.cs @ 12969

Last change on this file since 12969 was 12969, checked in by gkronber, 9 years ago

#2478 merged all changes from trunk to branch before trunk-reintegration

File size: 2.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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
22using System;
23
24namespace HeuristicLab.PluginInfrastructure {
25  /// <summary>
26  /// Enumerator of available file types for a plugin.
27  /// </summary>
28  public enum PluginFileType {
29    /// <summary>
30    /// CLR assembly files are loaded by the plugin infrastructure.
31    /// </summary>
32    Assembly,
33    /// <summary>
34    /// Native DLL files are ignored by the plugin infrastructure.
35    /// </summary>
36    NativeDll,
37    /// <summary>
38    /// Data files are any kind of support file for your plugin.
39    /// </summary>
40    Data,
41    /// <summary>
42    /// License files contain the license text of the plugin (ASCII encoding).
43    /// </summary>
44    License
45  };
46
47  /// <summary>
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.
50  /// </summary>
51  [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
52  public sealed class PluginFileAttribute : System.Attribute {
53    private string fileName;
54
55    /// <summary>
56    /// Gets the file name of the plugin.
57    /// </summary>
58    public string FileName {
59      get { return fileName; }
60    }
61
62    private PluginFileType fileType = PluginFileType.Data;
63
64    /// <summary>
65    /// Gets the file type of the plugin file.
66    /// </summary>
67    public PluginFileType FileType {
68      get { return fileType; }
69    }
70
71    /// <summary>
72    /// Initializes a new instance of <see cref="PluginFileAttribute"/>.
73    /// <param name="fileName">Name of the file</param>
74    /// <param name="fileType">Type of the file (Assembly, NativeDll, Data, License)</param>
75    /// </summary>
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;
81    }
82  }
83}
Note: See TracBrowser for help on using the repository browser.