Beispiel #1
0
        public void ProcessPlugin(
            object input,
            string path,
            bool alwaysOnTop,
            object secondaryArg,
            Form mainForm
            )
        {
            if (func.inputRequired && input == null)
            {
                return;
            }

            if (mainForm != null && func.hideMainForm)
            {
                mainForm.Hide();
            }

            object res = null;

            if (pi.dllType == "cpp")
            {
                IntPtr pluginPtr = NativeMan.LoadLibrary(dllPath);
                IntPtr funcPtr   = NativeMan.GetProcAddressOrdinal(pluginPtr, func.name);
                var    callback  = Marshal.GetDelegateForFunctionPointer <PluginMan.RunFunction>(funcPtr);
                res = callback(input, path, darkMode, langCode, alwaysOnTop, secondaryArg);
            }
            else if (pi.dllType == "csharp")
            {
                Assembly assembly = Assembly.LoadFrom(dllPath);
                Type     type     = assembly.GetType(Path.GetFileNameWithoutExtension(dllPath).Replace("-", "_") + ".Main");
                object   instance = Activator.CreateInstance(type);
                res = type.GetMethod(func.name).Invoke(instance, new object[] {
                    input,
                    path,
                    darkMode,
                    langCode,
                    alwaysOnTop,
                    secondaryArg
                }) as object;
            }

            if (res != null)
            {
                PluginMan.OutputEventArgs oea = new PluginMan.OutputEventArgs
                {
                    input = res
                };
                OnOutput(oea);
            }
        }
Beispiel #2
0
 protected virtual void OnOutput(PluginMan.OutputEventArgs e)
 {
     Output?.Invoke(this, e);
 }