/// <summary>
        /// Mark plugin as uninstalled
        /// </summary>
        /// <param name="systemName">Plugin system name</param>
        public static async Task MarkPluginAsUninstalled(string systemName)
        {
            if (string.IsNullOrEmpty(systemName))
            {
                throw new ArgumentNullException("systemName");
            }

            var filePath = CommonHelper.MapPath(InstalledPluginsFilePath);

            if (!File.Exists(filePath))
            {
                using (File.Create(filePath))
                {
                    //we use 'using' to close the file after it's created
                }
            }


            var installedPluginSystemNames = PluginFileParser.ParseInstalledPluginsFile(GetInstalledPluginsFilePath());
            var alreadyMarkedAsInstalled   = installedPluginSystemNames
                                             .FirstOrDefault(x => x.Equals(systemName, StringComparison.OrdinalIgnoreCase)) != null;

            if (alreadyMarkedAsInstalled)
            {
                installedPluginSystemNames.Remove(systemName);
            }
            await PluginFileParser.SaveInstalledPluginsFile(installedPluginSystemNames, filePath);
        }
Beispiel #2
0
        /// <summary>
        /// Mark plugin as installed
        /// </summary>
        /// <param name="systemName">Plugin system name</param>
        public static void MarkPluginAsInstalled(string systemName)
        {
            if (String.IsNullOrEmpty(systemName))
            {
                throw new ArgumentNullException("systemName");
            }

            var filePath = CommonHelper.MapPath(InstalledPluginsFilePath);

            if (!File.Exists(filePath))
            {
                using (File.Create(filePath))
                {
                    //we use 'using' to close the file after it's created
                }
            }


            var  installedPluginSystemNames = PluginFileParser.ParseInstalledPluginsFile(GetInstalledPluginsFilePath());
            bool alreadyMarkedAsInstalled   = installedPluginSystemNames
                                              .FirstOrDefault(x => x.Equals(systemName, StringComparison.InvariantCultureIgnoreCase)) != null;

            if (!alreadyMarkedAsInstalled)
            {
                installedPluginSystemNames.Add(systemName);
            }
            PluginFileParser.SaveInstalledPluginsFile(installedPluginSystemNames, filePath);
        }