/// <summary> /// Loads an IModule from a .DLL file. /// </summary> /// <param name="dllName">full path to the .DLL file</param> /// <returns>IModule if loaded successfully, null if not</returns> public static IModule LoadModule(string dllName) { IModule result = (IModule)StaticDllManager.Load(dllName, ModuleInterfaceName); // Registers the modules command with its .DLL file path. if (result != null) { if (CommandRegistry.ContainsKey(result.Command)) { Core.HandleEx(new Exception("LoadModule could not load '" + dllName + "' because a module with the command '" + result.Command + "' has already been loaded.")); } else { CommandRegistry.Add(result.Command, dllName); } } return(result); }
/// <summary> /// Searches for a loaded instance of the module with the given the full path of .DLL /// </summary> /// <param name="dllName">full path of dll file</param> /// <returns>the found instance or null if not found</returns> public static IModule GetExistingModule(string dllName) { return((IModule)StaticDllManager.GetExistingInstance(dllName, ModuleInterfaceName)); }
/// <summary> /// Unloads all modules from address space and clears the command registry. /// </summary> public static void UnloadModules() { StaticDllManager.Unload(); CommandRegistry.Clear(); }