1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2008 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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Text;
|
---|
25 | using System.IO;
|
---|
26 |
|
---|
27 | namespace HeuristicLab.PluginInfrastructure {
|
---|
28 | /// <summary>
|
---|
29 | /// Enumerator of available file types for a plugin.
|
---|
30 | /// </summary>
|
---|
31 | public enum PluginFileType {
|
---|
32 | Assembly,
|
---|
33 | NativeDll,
|
---|
34 | Data,
|
---|
35 | License
|
---|
36 | };
|
---|
37 |
|
---|
38 | /// <summary>
|
---|
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.
|
---|
41 | /// </summary>
|
---|
42 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
---|
43 | public sealed class PluginFileAttribute : System.Attribute {
|
---|
44 | private string fileName;
|
---|
45 |
|
---|
46 | /// <summary>
|
---|
47 | /// Gets the file name of the plugin.
|
---|
48 | /// </summary>
|
---|
49 | public string FileName {
|
---|
50 | get { return fileName; }
|
---|
51 | }
|
---|
52 |
|
---|
53 | private PluginFileType fileType = PluginFileType.Data;
|
---|
54 |
|
---|
55 | /// <summary>
|
---|
56 | /// Gets the file type of the plugin file.
|
---|
57 | /// </summary>
|
---|
58 | public PluginFileType FileType {
|
---|
59 | get { return fileType; }
|
---|
60 | }
|
---|
61 |
|
---|
62 | /// <summary>
|
---|
63 | /// Initializes a new instance of <see cref="PluginFileAttribute"/>.
|
---|
64 | /// <param name="fileName">Name of the file</param>
|
---|
65 | /// <param name="fileType">Type of the file (Assembly, NativeDll, Data, License)</param>
|
---|
66 | /// </summary>
|
---|
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;
|
---|
72 | }
|
---|
73 | }
|
---|
74 | }
|
---|