|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Linq; |
| 4 | +using System.Reflection; |
4 | 5 | using System.Text; |
5 | 6 | using System.Threading.Tasks; |
6 | 7 |
|
7 | 8 | namespace Torch.API.Plugins |
8 | 9 | { |
| 10 | + /// <summary> |
| 11 | + /// Indicates that the given type should be loaded by the plugin manager as a plugin. |
| 12 | + /// </summary> |
| 13 | + [AttributeUsage(AttributeTargets.Class)] |
9 | 14 | public class PluginAttribute : Attribute |
10 | 15 | { |
| 16 | + /// <summary> |
| 17 | + /// The display name of the plugin |
| 18 | + /// </summary> |
11 | 19 | public string Name { get; } |
| 20 | + /// <summary> |
| 21 | + /// The version of the plugin |
| 22 | + /// </summary> |
12 | 23 | public Version Version { get; } |
| 24 | + /// <summary> |
| 25 | + /// The GUID of the plugin |
| 26 | + /// </summary> |
13 | 27 | public Guid Guid { get; } |
14 | 28 |
|
| 29 | + /// <summary> |
| 30 | + /// Creates a new plugin attribute with the given attributes |
| 31 | + /// </summary> |
| 32 | + /// <param name="name"></param> |
| 33 | + /// <param name="version"></param> |
| 34 | + /// <param name="guid"></param> |
15 | 35 | public PluginAttribute(string name, string version, string guid) |
16 | 36 | { |
17 | 37 | Name = name; |
18 | 38 | Version = Version.Parse(version); |
19 | 39 | Guid = Guid.Parse(guid); |
20 | 40 | } |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Creates a new plugin attribute with the given attributes. Version is computed as the version of the assembly containing the given type. |
| 44 | + /// </summary> |
| 45 | + /// <param name="name"></param> |
| 46 | + /// <param name="versionSupplier">Version is this type's assembly's version</param> |
| 47 | + /// <param name="guid"></param> |
| 48 | + public PluginAttribute(string name, Type versionSupplier, string guid) |
| 49 | + { |
| 50 | + Name = name; |
| 51 | + Version = versionSupplier.Assembly.GetName().Version; |
| 52 | + Guid = Guid.Parse(guid); |
| 53 | + } |
21 | 54 | } |
22 | 55 | } |
0 commit comments