Game Development Reference
In-Depth Information
The following method is invoked from the ReloadPluginsThread method, and is
used to reload the plugin list from the plugins directory.
private void ReloadPlugins()
{
if (!started)
{
throw new InvalidOperationException(“PluginManager not started.”);
}
lock (lockObject)
{
LoadPluginDirectory();
changeTime = new DateTime(0);
if (ReloadedPlugins != null)
ReloadedPlugins(this, EventArgs.Empty);
}
}
The following method is the event handler for the FileSystemWatcher object. This
handler is invoked whenever the plugin directory changes. A new change time is
set so that the reload thread will fire 10 seconds from the current time.
void fileSystemWatcher_Changed(object sender, FileSystemEventArgs e)
{
changeTime = DateTime.Now + new TimeSpan(0, 0, 10);
}
The following method is used to load a plugin from the specified path. A new
PluginLibrary instance is created for the plugin and returned if successful.
private PluginLibrary LoadPlugin(DirectoryInfo pluginDirectory,
FileInfo pluginFile)
{
bool success = false;
PluginLibrary plugin = null;
try
{
plugin = new PluginLibrary();
Search Nedrilad ::




Custom Search