Game Development Reference
In-Depth Information
The following class keeps track of the loaded plugins, but it also contains the code
to watch the file system for changes, reloading the plugins when appropriate.
using System;
using System.IO;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
namespace Plugin.Manager
{
public class PluginCatalogue
{
private FileSystemWatcher fileSystemWatcher = null;
private string lockObject = “{RELOAD_PLUGINS_LOCK}”;
private DateTime changeTime = new DateTime(0);
private Thread pluginReloadThread = null;
private readonly List<PluginLibrary> plugins
= new List<PluginLibrary>();
private bool beginShutdown = false;
private bool active = true;
private bool started = false;
private bool autoReload = true;
private string pluginDirectory = string.Empty;
public event EventHandler ReloadedPlugins;
public event EventHandler UnloadedPlugins;
public List<PluginLibrary> Plugins
{
get { return plugins; }
}
The following property is used to stop and start automatic plugin reloading at
runtime, which is useful if you want to make it a user setting.
public bool AutoReload
{
get
{
return autoReload;
}
set
Search Nedrilad ::




Custom Search