public void AddEntry(HostEntry entry) { if (entry == null) { throw new ArgumentNullException("entry"); } if (HostEntry.IsIgnoredHostname(entry.Hostname)) { throw new ArgumentException("The following hostnames cannot be configured: " + String.Join(", ", HostEntry.IgnoredHostnames)); } if (!entries.Contains(entry)) { entries.Add(entry); } }
public void DeleteEntry(HostEntry entry) { if (entry == null) { throw new ArgumentNullException("entry"); } if (entries.Contains(entry)) { if (!(entry.IsNew || deletedLines.Contains(entry.Line))) { deletedLines.Add(entry.Line); } entries.Remove(entry); } }
private void Load(Stream stream) { deletedLines = new List <int>(); this.lines = ReadAllLines(stream); List <HostEntry> entriesList = new List <HostEntry>(); for (int i = 0; i < lines.Length; i++) { HostEntry entry = ParseHostEntry(i, lines[i]); if (!(entry == null || HostEntry.IsIgnoredHostname(entry.Hostname))) { entriesList.Add(entry); } } this.entries = entriesList; }