/// <summary> /// 文件的一行数据 /// </summary> /// <param name="text">原始文本</param> /// <param name="file">hosts 文件读写</param> /// <param name="lineIndex">文本中的第几行</param> internal FileLine(string text, HostsFile file, int lineIndex) { this.text = text; this.file = file; this.lineIndex = lineIndex; int noteIndex = text.IndexOf('#'); if (noteIndex != -1) { note = text.Substring(noteIndex); text = noteIndex != 0 ? text.Substring(0, noteIndex) : string.Empty; } if (!string.IsNullOrEmpty(text)) { domains = text.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); if (domains.Length > 1) { string ip = null; foreach (string domain in domains) { if (ip == null) { ip = domain; } else { file.domains[domain] = this; } } } } if (note == null && domains == null) { file.emptyLines.Add(lineIndex); } }
/// <summary> /// 文件的一行数据 /// </summary> /// <param name="file"></param> /// <param name="ip"></param> /// <param name="domain"></param> /// <param name="note"></param> /// <param name="lineIndex">文本中的第几行</param> internal FileLine(HostsFile file, string ip, string domain, string note, int lineIndex) { this.file = file; this.lineIndex = lineIndex; Set(ip, domain, note); }