/// <summary> /// Initializes the PluginManager by loading the cache from file. /// </summary> private void Initialize() { FileStream fs = new FileStream(_configPath, FileMode.Open); info = (PluginManagerDatabase)_serializer.Deserialize(fs); fs.Close(); }
/// <summary> /// Returns the plugin info by prefix. returns false if not containing /// </summary> /// <param name="pmd">The database that is cached</param> /// <param name="prefix">The prefix to be searched for</param> /// <param name="val">the out variable containing the plugin information(null if not found)</param> /// <returns>the success state of the operation</returns> public static bool TryGetPluginInfoByPrefix(PluginManagerDatabase pmd, string prefix, out PluginInformation val) { for (int i = 0; i < pmd.Cache.Count; i++) { if (pmd.Cache[i].Prefixes.Contains(prefix)) { val = pmd.Cache[i]; return(true); } } val = new PluginInformation(); return(false); }
/// <summary> /// Returns the plugin info by name. returns false if not containing /// </summary> /// <param name="pmd">The database that is cached</param> /// <param name="name">the name to be searched for</param> /// <param name="val">the out variable containing the plugin information(null if not found)</param> /// <returns>the success state of the operation</returns> public static bool TryGetPluginInfoByName(PluginManagerDatabase pmd, string name, out PluginInformation val) { for (int i = 0; i < pmd.Cache.Count; i++) { if (pmd.Cache[i].Name == name) { val = pmd.Cache[i]; return(true); } } val = new PluginInformation(); return(false); }
/// <summary> /// Gets executed when its the first start. /// Will set up the cache and will perform a refresh. /// </summary> private void FirstStart() { this.Log(DebugLevel.LOGS, Verbosity.LEVEL1, "First start of Plugin Manager. Setting up..."); FileStream fs = new FileStream(_configPath, FileMode.Create); info = new PluginManagerDatabase() { IncludedFiles = new List <string>(), Cache = new List <PluginInformation>(), IncludedDirectories = new List <string>() { _defaultPluginFolder } }; if (!Directory.Exists(_defaultPluginFolder)) { Directory.CreateDirectory(_defaultPluginFolder); } _serializer.Serialize(fs, info); fs.Close(); Refresh(); }