Exemple #1
0
 private static void GetPluginConfigInstance(IPlugin plugin,
     out ConfigBase config, out ConfigPanelBase configPanel)
 {
     config = null;
     configPanel = null;
     object[] attributes = plugin.GetType().GetCustomAttributes(typeof(PluginAttribute), false);
     if (attributes.Length > 0)
     {
         PluginAttribute attr = attributes[0] as PluginAttribute;
         config = Activator.CreateInstance(attr.ConfigType) as ConfigBase;
         config = LoadConfig(config, config.Key);
         configPanel = Activator.CreateInstance(attr.ConfigPanelType) as ConfigPanelBase;
     }
 }
Exemple #2
0
 private static void GetAssemblyConfig(Assembly assembly,
     out ConfigBase config, out ConfigPanelBase configPanel)
 {
     config = null;
     configPanel = null;
     foreach (Type type in assembly.GetExportedTypes())
     {
         if (config == null && type.IsSubclassOf(typeof(ConfigBase)))
         {
             config = Activator.CreateInstance(type) as ConfigBase;
             config = LoadConfig(config, config.Key);
         }
         if (configPanel == null && type.IsSubclassOf(typeof(ConfigPanelBase)))
         {
             configPanel = Activator.CreateInstance(type) as ConfigPanelBase;
         }
         if (config != null && configPanel != null)
         {
             break;
         }
     }
 }