Game Development Reference
In-Depth Information
if (plugin.Load(pluginDirectory, pluginFile))
{
success = true;
}
}
catch (Exception)
{
success = false;
}
if (!success)
{
MessageBox.Show(String.Format(“Could not load plugin [{0}].”,
pluginFile.Name));
plugin = null;
}
return plugin;
}
The following method is used to check the loaded plugin list and see if any of the
instances support the specified interface. This is used to return a list of compatible
plugins for the given interface. This method can be considered a caching optimiza-
tion so that the entire plugin list does not have to be checked when invoking a
method on a plugin interface.
public List<PluginLibrary> DeterminePluginTargets(Type interfaceTarget)
{
List<PluginLibrary> targets = new List<PluginLibrary>();
foreach (PluginLibrary library in plugins)
{
if (library.ImplementsInterface(interfaceTarget.Name))
{
targets.Add(library);
}
}
return targets;
}
The following method is used to return a list of valid plugin files from the specified
directory. This list will be the one that the plugin catalogue uses to load all the plugins.
Search Nedrilad ::




Custom Search