private bool AlreadyHaveLineForHostOf(HostFileLine hostFileLine) { var lowerHost = hostFileLine?.HostName?.ToLowerInvariant(); if (_knownHosts.Contains(lowerHost)) { return(true); } _knownHosts.Add(lowerHost); return(false); }
private void AddLine(string line, bool isPrimary, bool skipIfComment) { var hostFileLine = new HostFileLine(line, isPrimary); if ((hostFileLine.IsComment && skipIfComment) || (!isPrimary && AlreadyHaveLineForHostOf(hostFileLine))) { return; } _knownHosts.Add(hostFileLine.HostName.ToLowerInvariant()); _lines.Add(hostFileLine); }