예제 #1
0
        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;
        }
예제 #2
0
        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;
        }