Exemplo n.º 1
0
		public HostsItem(NetAddress ip, HostAliases hosts, string comment = "")
		{
			Enabled = true;
			IP = ip;
			Aliases = hosts;
			Comment = comment ?? "";
			Valid = true;
		}
Exemplo n.º 2
0
		public HostsItem(string ip, string[] hosts, string comment = "")
		{
			Enabled = true;
			IP = new NetAddress(ip);
			Aliases = new HostAliases(hosts);
			Comment = comment ?? "";
			Valid = true;
		}
Exemplo n.º 3
0
		public HostsItem(NetAddress ip, HostName host, string comment = "")
		{
			Enabled = true;
			IP = ip;
			Aliases = new HostAliases(host);
			Comment = comment ?? "";
			Valid = true;
		}
Exemplo n.º 4
0
		public bool Equals(NetAddress ip)
		{
			if ((object)ip == null) return false;
			return ip.IP == this.IP;
		}
Exemplo n.º 5
0
		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;
		}