public static void Load(string filename)
{
ScriptSource script = engine.CreateScriptSourceFromFile(filename);
ScriptScope scope = engine.CreateScope();
object o = script.Execute(scope);
if (o is IPlugin)
{
PluginManager.Load(o as IPlugin);
}
else
{
string name, author, description;
Version version;
if (!scope.TryGetVariable <string> ("name", out name))
{
name = "unknown";
}
if (!scope.TryGetVariable <string> ("author", out author))
{
author = "unknown";
}
if (!scope.TryGetVariable <string> ("description", out description))
{
description = "no description";
}
if (!scope.TryGetVariable <Version>("version", out version))
{
version = new Version(0, 0);
}
RubyPlugin.UnloadDelegate unload;
if (!scope.TryGetVariable <RubyPlugin.UnloadDelegate>("unload", out unload))
{
unload = null;
}
PluginManager.Load(new RubyPlugin(name, author, description, version, unload));
}
}