/// <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() { Logger.Log(LogType.Log, "First start of Plugin Manager. Setting up...", 1); 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(); }