public PluginManager() { if (File.Exists(pluginStateFile)) { try { this.Disabled = JsonConvert.DeserializeObject <HashSet <string> >(File.ReadAllText(pluginStateFile)); } catch { this.Disabled = new HashSet <string>(); } } else { this.Disabled = new HashSet <string>(); } if (File.Exists(knownPluginsFile)) { try { this.KnownPlugins = JsonConvert.DeserializeObject <List <PluginState> >(File.ReadAllText(knownPluginsFile)); } catch { } } var plugins = new List <IApplicationPlugin>(); foreach (var containerType in PluginFinder.FindTypes <IApplicationPlugin>().Where(type => Disabled.Contains(type.FullName) == false)) { try { plugins.Add(Activator.CreateInstance(containerType) as IApplicationPlugin); } catch (Exception ex) { Console.WriteLine("Error constructing plugin: " + ex.Message); } } this.Plugins = plugins; /* * // Uncomment to generate new KnownPlugins.json file * KnownPlugins = plugins.Where(p => p.MetaData != null).Select(p => new PluginState { TypeName = p.GetType().FullName, Name = p.MetaData.Name }).ToList(); * * File.WriteAllText( * Path.Combine("..", "..", "knownPlugins.json"), * JsonConvert.SerializeObject(KnownPlugins, Formatting.Indented)); */ }