Skip to content

Commit 67dba9c

Browse files
committed
PluginAttribute now lets you get the version from the loaded assembly
Documentation in PluginAttribute
1 parent 52c509a commit 67dba9c

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,55 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Reflection;
45
using System.Text;
56
using System.Threading.Tasks;
67

78
namespace Torch.API.Plugins
89
{
10+
/// <summary>
11+
/// Indicates that the given type should be loaded by the plugin manager as a plugin.
12+
/// </summary>
13+
[AttributeUsage(AttributeTargets.Class)]
914
public class PluginAttribute : Attribute
1015
{
16+
/// <summary>
17+
/// The display name of the plugin
18+
/// </summary>
1119
public string Name { get; }
20+
/// <summary>
21+
/// The version of the plugin
22+
/// </summary>
1223
public Version Version { get; }
24+
/// <summary>
25+
/// The GUID of the plugin
26+
/// </summary>
1327
public Guid Guid { get; }
1428

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>
1535
public PluginAttribute(string name, string version, string guid)
1636
{
1737
Name = name;
1838
Version = Version.Parse(version);
1939
Guid = Guid.Parse(guid);
2040
}
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+
}
2154
}
2255
}

0 commit comments

Comments
 (0)