This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PDKAttributes.cs
74 lines (74 loc) · 3.47 KB
/
PDKAttributes.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
namespace Blusutils.DESrv.PDK {
/// <summary>
/// This attribute tags class as PDK extension
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class PDKExtensionAttribute : Attribute {
/// <summary>
/// Extension metadata
/// </summary>
public ExtensionMetadata Metadata { get; private set; }
/// <summary>
/// Create a new instance of attribute
/// </summary>
/// <param name="ID">ID of the extension, must be unique and contain only A-Z, a-z, 0-9, _ symbols</param>
/// <param name="ExtensionType">Type of the extension, means how it will be loaded</param>
/// <param name="Name">Readable name of the extension</param>
/// <param name="Author">Who was authored this extension</param>
/// <param name="Version">Version of the extension</param>
/// <param name="TargetDESrvVersion">Minimum DESrv version with which the extension is compatible;
/// checks according to the SemVer principle
/// (major - incompatible, minor - compatible to a greater extent, minor and patch - fully compatible)</param>
/// <param name="Description">Description of the extension</param>
/// <param name="Link">Link to resource related to extension</param>
/// <param name="AllowedPorts">What ports should be allowed for this extension (behavior is controlled by the DESrv config)</param>
/// <param name="Dependencies">List of extensions on which this extension depends</param>
/// <param name="RefersTo">Parent extension ID (if the current extension is an addon)</param>
public PDKExtensionAttribute(string ID,
ExtensionType ExtensionType,
string Name,
string Author,
string Version,
string TargetDESrvVersion,
string? Description = null,
string? Link = null,
int[]? AllowedPorts = null,
string[]? Dependencies = null,
string? RefersTo = null
) {
Metadata = new() {
ID = ID,
ExtensionType = ExtensionType,
Name = Name,
Author = Author,
Version = new Version(Version),
TargetDESrvVersion = new Version(TargetDESrvVersion),
Description = Description,
Link = Link,
AllowedPorts = AllowedPorts,
Dependencies = Dependencies,
RefersTo = RefersTo
};
}
}
/// <summary>
/// This attribute tags method as extension entrypoint that calls on start and runs forever
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class ExtensionEntrypointAttribute : Attribute { }
/// <summary>
/// This attribute tags method as event that calls every time when extension loads
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class ExtensionOnLoadAttribute : Attribute { }
/// <summary>
/// This attribute tags method as event that calls every time when extension unloads
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class ExtensionOnUnloadAttribute : Attribute { }
/// <summary>
/// This attribute tags method as extension addon loader that calls every time when DESrv PDK tries to load addon to this extension
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class ExtensionAddonLoaderAttribute : Attribute { }
}