private static IJinxBotPlugin Instantiate(PluginInfo info, ProfilePluginConfiguration config) { IJinxBotPlugin plugin = Activator.CreateInstance(info.Type) as IJinxBotPlugin; if (plugin == null) throw new InvalidCastException("Could not cast \"" + info.Type.FullName + "\" to \"IJinxBotPlugin\"."); Dictionary<string, string> settings = config.Settings.ToDictionary(s => s.Name, s => s.Value); plugin.Startup(settings); return plugin; }
private static bool LoadType(ProfilePluginConfiguration pluginConfiguration) { Assembly asm = m_loadedAssemblies[pluginConfiguration.Assembly]; Type type = asm.GetType(pluginConfiguration.Type, false, false); if (type != null) { JinxBotPluginAttribute[] attr = type.GetCustomAttributes(typeof(JinxBotPluginAttribute), false) as JinxBotPluginAttribute[]; if (attr.Length == 0) return false; PluginInfo info = new PluginInfo(attr[0], type); m_pluginTypes.Add(pluginConfiguration.Type, info); return true; } return false; }