Beispiel #1
0
        public static void AddPlugin(
            IntPtr thisPtr,
            IntPtr deletePtr,
            PTMF initializePtr,
            PTMF updatePtr)
        {
            if (thisPtr == IntPtr.Zero)
            {
                throw new Exception("thisPtr");
            }
            if (deletePtr == IntPtr.Zero)
            {
                throw new Exception("deletePtr");
            }
            if (initializePtr.FunctionPtr == IntPtr.Zero)
            {
                throw new Exception("initializePtr");
            }
            if (updatePtr.FunctionPtr == IntPtr.Zero)
            {
                throw new Exception("updatePtr");
            }

            var module = IntPtr.Zero; // The calling module will handle it own lifecycle.

            var delete = (UnmanagedActionMethod)Marshal.GetDelegateForFunctionPointer(
                deletePtr,
                typeof(UnmanagedActionMethod)
                );
            var initialize = (UnmanagedActionMethod)Marshal.GetDelegateForFunctionPointer(
                initializePtr.FunctionPtr,
                typeof(UnmanagedActionMethod)
                );
            var update = (UnmanagedActionMethod)Marshal.GetDelegateForFunctionPointer(
                updatePtr.FunctionPtr,
                typeof(UnmanagedActionMethod)
                );
            var plugin = new UnmanagedPlugin(module, thisPtr, delete, initialize, update);

            Singleton <PluginManager> .Instance.AddPlugin(plugin);
        }
Beispiel #2
0
        /// <summary>
        /// Loads a native plugin from a native shared library
        /// </summary>
        /// <param name="name"></param>
        public static void LoadNativePlugin(string name)
        {
            var plugin = UnmanagedPlugin.CreateNativePlugin(name);

            Singleton <PluginManager> .Instance.AddPlugin(plugin);
        }