-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNativeFunction.cs
More file actions
57 lines (54 loc) · 2.51 KB
/
NativeFunction.cs
File metadata and controls
57 lines (54 loc) · 2.51 KB
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
namespace NativeFunctionLoader;
/// <summary>
/// An attribute which marks fields for the function injection
/// The field has to be public static readonly
/// <remarks>
/// <b>Authors:</b> Marlon Klaus<br></br>
/// <b>Created by:</b> Marlon Klaus<br></br>
/// <b>Created on:</b> 10/27/2021<br></br>
/// <b>Since:</b> 1.0.0.0
/// </remarks>
/// </summary>
[AttributeUsage(AttributeTargets.Field)]
public sealed class NativeFunction : Attribute {
internal Platforms Platforms { get; }
internal string[] LibraryNames { get; }
internal string? CustomFunctionName { get; }
internal bool HasToExist { get; }
/// <summary>
/// The NativeFunction attribute constructor
/// <remarks>
/// <b>Authors:</b> Marlon Klaus<br></br>
/// <b>Created by:</b> Marlon Klaus<br></br>
/// <b>Created on:</b> 10/27/2021<br></br>
/// <b>Since:</b> 1.0.0.0
/// </remarks>
/// </summary>
/// <param name="platforms">This function should be injected on this platforms</param>
/// <param name="libraryName">The name of the library</param>
/// <param name="customFunctionName">A custom name for the native function. Set this to null to use the name of the field</param>
/// <param name="hasToExist">If this is set to false, no exception will be thrown when a function fails to inject</param>
public NativeFunction(Platforms platforms, string libraryName, string? customFunctionName = null,
bool hasToExist = true) : this(platforms, new[] { libraryName }, customFunctionName, hasToExist) {
}
/// <summary>
/// The NativeFunction attribute constructor
/// <remarks>
/// <b>Authors:</b> Marlon Klaus<br></br>
/// <b>Created by:</b> Marlon Klaus<br></br>
/// <b>Created on:</b> 10/27/2021<br></br>
/// <b>Since:</b> 1.0.0.0
/// </remarks>
/// </summary>
/// <param name="platforms">This function should be injected on this platforms</param>
/// <param name="libraryNames">Possible names of the library</param>
/// <param name="customFunctionName">A custom name for the native function. Set this to null to use the name of the field</param>
/// <param name="hasToExist">If this is set to false, no exception will be thrown when a function fails to inject</param>
public NativeFunction(Platforms platforms, string[] libraryNames, string? customFunctionName = null,
bool hasToExist = true) {
Platforms = platforms;
LibraryNames = libraryNames;
CustomFunctionName = customFunctionName;
HasToExist = hasToExist;
}
}