get assembly and main module after loading the plugin
This commit is contained in:
@@ -9,12 +9,21 @@ Public Class Plugin
|
|||||||
''' </summary>
|
''' </summary>
|
||||||
''' <returns></returns>
|
''' <returns></returns>
|
||||||
Public ReadOnly Property MainFunctions As IReadOnlyList(Of PluginFunction)
|
Public ReadOnly Property MainFunctions As IReadOnlyList(Of PluginFunction)
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' A collection of Methods with a FunctionCode (excluding all PluginFunctions from MainFunctions).
|
''' A collection of Methods with a FunctionCode (excluding all PluginFunctions from MainFunctions).
|
||||||
''' </summary>
|
''' </summary>
|
||||||
''' <returns></returns>
|
''' <returns></returns>
|
||||||
Public ReadOnly Property PluginFunctions As IReadOnlyList(Of PluginFunction)
|
Public ReadOnly Property PluginFunctions As IReadOnlyList(Of PluginFunction)
|
||||||
|
''' <summary>
|
||||||
|
''' Gets the assembly that contains the PluginFunctions of this Plugin
|
||||||
|
''' </summary>
|
||||||
|
''' <returns></returns>
|
||||||
|
Public ReadOnly Property Assembly As Assembly
|
||||||
|
''' <summary>
|
||||||
|
''' Gets the main module that contains the PluginFunctions of this Plugin
|
||||||
|
''' </summary>
|
||||||
|
''' <returns></returns>
|
||||||
|
Public ReadOnly Property MainModule As Type
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' Load a new Plugin and its PluginFunctions.
|
''' Load a new Plugin and its PluginFunctions.
|
||||||
@@ -23,10 +32,10 @@ Public Class Plugin
|
|||||||
''' <param name="autoCallMainFunction">If true, all MainMethods of a Plugin will be called as soon as a Plugin is loaded.</param>
|
''' <param name="autoCallMainFunction">If true, all MainMethods of a Plugin will be called as soon as a Plugin is loaded.</param>
|
||||||
''' <param name="entryTypeName">The name of the type where to search for Methods when loading a new Plugin.</param>
|
''' <param name="entryTypeName">The name of the type where to search for Methods when loading a new Plugin.</param>
|
||||||
Public Sub New(filePath As String, autoCallMainFunction As Boolean, entryTypeName As String)
|
Public Sub New(filePath As String, autoCallMainFunction As Boolean, entryTypeName As String)
|
||||||
Dim asm As Assembly = Assembly.LoadFile(filePath)
|
Assembly = Assembly.LoadFile(filePath)
|
||||||
Dim modul As Type = asm.GetType(entryTypeName)
|
MainModule = Assembly.GetType(entryTypeName)
|
||||||
|
|
||||||
If modul Is Nothing Then
|
If MainModule Is Nothing Then
|
||||||
Throw New PluginLoadException("Plugin Modul not found!")
|
Throw New PluginLoadException("Plugin Modul not found!")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@@ -39,7 +48,7 @@ Public Class Plugin
|
|||||||
Dim implementMethods As New List(Of PluginFunction)
|
Dim implementMethods As New List(Of PluginFunction)
|
||||||
|
|
||||||
'Search for PluginFunctions
|
'Search for PluginFunctions
|
||||||
For Each mi As MethodInfo In modul.GetMethods
|
For Each mi As MethodInfo In MainModule.GetMethods
|
||||||
Dim found As Boolean = False
|
Dim found As Boolean = False
|
||||||
|
|
||||||
'Check if the method has one of the defined attributes
|
'Check if the method has one of the defined attributes
|
||||||
|
|||||||
Reference in New Issue
Block a user