private static HostMap[] GetMaps() { var maps = new List <HostMap>(); foreach (var line in HostFileLines) { if (HostMap.TryParse(line, out var map)) { maps.Add(map); } } return(maps.ToArray()); }
public static void Add(HostMap myMap) { foreach (var line in HostFileLines) { if (HostMap.TryParse(line, out var map)) { if (map.Equals(myMap)) { return; } } } var hostFileLines = HostFileLines.Append(myMap.ToString()); SaveHostFile(hostFileLines); }
public static void RemoveByHostName(string hostname) { var hostFileLines = HostFileLines.ToList(); foreach (var line in hostFileLines) { if (HostMap.TryParse(line, out var map)) { if (map.HostName == hostname) { hostFileLines.Remove(line); break; } } } SaveHostFile(hostFileLines); }
public static void RemoveByIp(IPAddress ip) { var hostFileLines = HostFileLines.ToList(); foreach (var line in hostFileLines) { if (HostMap.TryParse(line, out var map)) { if (map.Address.Equals(ip)) { hostFileLines.Remove(line); break; } } } SaveHostFile(hostFileLines); }
public static void Add(string mapLine) { HostMap.TryParse(mapLine, out var map); Add(map); }