Game Development Reference
In-Depth Information
The following method uses reflection to call the Release() method directly on the
IPlugin instance.
private void ExecuteReleaseMethod(IPlugin plugin)
{
ExecuteMethodNoReturn(plugin, “Release”, null);
}
The following method uses reflection to call a method directly on the IPlugin
instance. This call does not return any values.
private void ExecuteMethodNoReturn(IPlugin plugin,
string methodName,
object[] parameters)
{
MethodInfo method = plugin.GetType().GetMethod(methodName);
if (method != null)
method.Invoke(plugin, parameters);
}
The following method uses reflection to call a method directly on the IPlugin
instance. This call returns values.
private object ExecuteMethodWithReturn(IPlugin plugin,
string methodName,
object[] parameters)
{
MethodInfo method = plugin.GetType().GetMethod(methodName);
if (method != null)
return method.Invoke(plugin, parameters);
return null;
}
#endregion
}
}
Loading Plugins Through the Proxy
With the proxy created, we can now move on to loading plugins and accessing
them through the proxy. The following class wraps each plugin assembly and
Search Nedrilad ::




Custom Search