diff --git a/src/Delegate.Daxif.Scripts/Resources/Plugin.cs b/src/Delegate.Daxif.Scripts/Resources/Plugin.cs
index c0a4c49..9876ccc 100644
--- a/src/Delegate.Daxif.Scripts/Resources/Plugin.cs
+++ b/src/Delegate.Daxif.Scripts/Resources/Plugin.cs
@@ -124,11 +124,27 @@ protected string ChildClassName {
/// Initializes a new instance of the class.
///
/// The of the derived class.
- internal Plugin(Type childClassName) {
+ internal Plugin(Type childClassName) : this(childClassName, null, null) { }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ ///
+ internal Plugin(Type childClassName, string unsecure) : this(childClassName, unsecure, null) { }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ ///
+ ///
+ internal Plugin(Type childClassName, string unsecure, string secure) {
this.ChildClassName = childClassName.ToString();
}
+
///
/// Executes the plug-in.
///
diff --git a/src/Delegate.Daxif/Modules/Plugins/Domain.fs b/src/Delegate.Daxif/Modules/Plugins/Domain.fs
index b0555ce..0415aab 100644
--- a/src/Delegate.Daxif/Modules/Plugins/Domain.fs
+++ b/src/Delegate.Daxif/Modules/Plugins/Domain.fs
@@ -157,4 +157,6 @@ type AssemblyRegistration = {
{
id = e.Id
hash = e.GetAttributeValue("sourcehash")
- }
\ No newline at end of file
+ }
+
+type PluginConstructorType = Empty | Unsecure | Secure
\ No newline at end of file
diff --git a/src/Delegate.Daxif/Modules/Plugins/PluginDetection.fs b/src/Delegate.Daxif/Modules/Plugins/PluginDetection.fs
index a250dc5..5e77fed 100644
--- a/src/Delegate.Daxif/Modules/Plugins/PluginDetection.fs
+++ b/src/Delegate.Daxif/Modules/Plugins/PluginDetection.fs
@@ -176,17 +176,30 @@ let getValidPlugins (types:Type[]) =
let validTypes, invalidTypes =
types
|> Array.filter (fun (x:Type) -> x.IsSubclassOf(pluginType.Value))
- |> Array.partition (fun (x:Type) -> not x.IsAbstract && x.GetConstructor(Type.EmptyTypes) <> null)
+ |> Array.map (fun (x:Type) ->
+ let constructorType =
+ match x.GetConstructor(Type.EmptyTypes) <> null, x.GetConstructor([|typeof|]) <> null, x.GetConstructor([|typeof; typeof|]) <> null with
+ | true,_,_ -> Some PluginConstructorType.Empty
+ | _,true,_ -> Some PluginConstructorType.Unsecure
+ | _,_,true -> Some PluginConstructorType.Secure
+ | false,false,false -> None
+
+ x,constructorType
+ )
+ |> Array.partition (fun (x:Type, constructor: PluginConstructorType option) ->
+ not x.IsAbstract && constructor.IsSome
+ )
invalidTypes
- |> Array.iter (fun (x:Type) ->
+ |> Array.iter (fun (x:Type, constructor: PluginConstructorType option) ->
if x.IsAbstract
then log.Warn "The plugin '%s' is an abstract type and is therefore not valid. The plugin will not be synchronized" (x.Name)
- if x.GetConstructor(Type.EmptyTypes) = null
- then log.Warn "The plugin '%s' does not contain an empty contructor and is therefore not valid. The plugin will not be synchronized" (x.Name)
+ if constructor.IsNone
+ then log.Warn "The plugin '%s' does not contain a valid contructor and is therefore not valid. The plugin will not be synchronized" (x.Name)
)
validTypes
+ |> Array.map (fun (x: Type, constructor: PluginConstructorType option) -> x,constructor.Value)
/// Calls "PluginProcessingStepConfigs" in the plugin assembly that returns a
/// tuple containing the plugin information
@@ -197,8 +210,14 @@ let getPluginsFromAssembly (asm: Assembly) =
|> fun validPlugins ->
validPlugins
- |> Array.Parallel.map (fun (x:Type) ->
- Activator.CreateInstance(x), x.GetMethod(@"PluginProcessingStepConfigs"))
+ |> Array.Parallel.map (fun (x:Type, constructorType: PluginConstructorType) ->
+ let instance =
+ match constructorType with
+ | Empty -> Activator.CreateInstance(x)
+ | Unsecure -> Activator.CreateInstance(x, [|null|])
+ | Secure -> Activator.CreateInstance(x, [|null;null|])
+
+ instance, x.GetMethod(@"PluginProcessingStepConfigs"))
|> Array.Parallel.map (fun (x, (y:MethodInfo)) ->
y.Invoke(x, [||]) :?>
((string * int * string * string) *
@@ -229,7 +248,7 @@ let getValidCustomAPIs(types:Type[]) =
|> Array.iter (fun (x:Type) ->
if x.IsAbstract
then log.Warn "The custom api '%s' is an abstract type and is therefore not valid. The custom api will not be synchronized" (x.Name)
- if x.GetConstructor(Type.EmptyTypes) = null
+ if x.GetConstructor(Type.EmptyTypes) = null
then log.Warn "The custom api '%s' does not contain an empty contructor and is therefore not valid. The custom api will not be synchronized" (x.Name)
)