public HostsItem(NetAddress ip, HostAliases hosts, string comment = "") { Enabled = true; IP = ip; Aliases = hosts; Comment = comment ?? ""; Valid = true; }
public HostsItem(string ip, string[] hosts, string comment = "") { Enabled = true; IP = new NetAddress(ip); Aliases = new HostAliases(hosts); Comment = comment ?? ""; Valid = true; }
public HostsItem(NetAddress ip, HostName host, string comment = "") { Enabled = true; IP = ip; Aliases = new HostAliases(host); Comment = comment ?? ""; Valid = true; }
public bool Equals(NetAddress ip) { if ((object)ip == null) return false; return ip.IP == this.IP; }
public bool Parse(string value) { SourceString = value; try { var match = HostRowPattern.Match(value); if (!match.Success) throw new FormatException(); Enabled = value[0] != '#'; IP = new NetAddress(match.Groups["ip"].Value); Aliases = new HostAliases(match.Groups["hosts"].Value); Comment = match.Groups["comment"].Value; Hidden = false; if (!String.IsNullOrEmpty(Comment)) { Hidden = Comment[0] == '!'; if (Hidden) Comment = Comment.Substring(1).Trim(); } Valid = true; } catch { Enabled = false; Hidden = false; IP = null; Aliases = null; Comment = null; Valid = false; } SourceHash = HalfMD5.ComputeHash(ToString()); return Valid; }