internal void UpdateExtensions(IEnumerable <PHPIniExtension> extensions) { foreach (PHPIniExtension extension in extensions) { int foundIndex = -1; for (int i = 0; i < RawEntries.Count; i++) { PHPIniBase b = RawEntries[i]; PHPIniExtension existing = b as PHPIniExtension; if (existing != null) { if (String.Equals(existing.Name, extension.Name, StringComparison.OrdinalIgnoreCase)) { foundIndex = i; break; } } } // If extension is found... if (foundIndex >= 0) { // ... and is disabled then... if (!extension.Enabled) { PHPIniBase extensionLine = RawEntries[foundIndex]; // ... remove the extension section name if it exists if (foundIndex > 0 && String.Equals(RawEntries[foundIndex - 1].GetText(), GetExtensionSection(extension.Name), StringComparison.OrdinalIgnoreCase)) { RawEntries.Remove(RawEntries[foundIndex - 1]); } // remove the exension RawEntries.Remove(extensionLine); } } else { // Extension is not found if (extension.Enabled) { extension.UpdateText(); // Add it at the end of the file along with the extension section name int lastIndex = RawEntries.Count - 1; lastIndex++; RawEntries.Insert(lastIndex, new PHPIniString(GetExtensionSection(extension.Name))); lastIndex++; RawEntries.Insert(lastIndex, extension); } } } }
internal bool Remove(PHPIniBase entry) { return(RawEntries.Remove(entry)); }