Exemple #1
0
        private bool AlreadyHaveLineForHostOf(HostFileLine hostFileLine)
        {
            var lowerHost = hostFileLine?.HostName?.ToLowerInvariant();

            if (_knownHosts.Contains(lowerHost))
            {
                return(true);
            }
            _knownHosts.Add(lowerHost);
            return(false);
        }
Exemple #2
0
        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);
        }