/// <summary> /// Tagses the specified presious. /// </summary> /// <param name="files">The files.</param> /// <returns></returns> public List<string> Tags(List<string> files ) { foreach (var file in files) { _fileReader = new FileReader(file); _length = _fileReader.Length(); long currentPosition = 0; var trigger = string.Empty; var skip = false; var inTrigger = false; while (_length > currentPosition) { var s = _fileReader.ReadString(1); currentPosition++; if (s == "<") { trigger = string.Empty; skip = false; inTrigger = true; } trigger = trigger + s; if (s == " ") { if (inTrigger) { if (!_tags.Contains(trigger)) { _tags.Add(trigger); } trigger = string.Empty; skip = true; inTrigger = false; } } if (s == ">") { if (!skip) { if (inTrigger) { if (!_tags.Contains(trigger)) { _tags.Add(trigger); } trigger = string.Empty; inTrigger = false; } } } } } return _tags; }
/// <summary> /// Bounces the specified tags. /// </summary> /// <param name="tags">The tags.</param> /// <param name="files">The files.</param> public void Bounce(List<string> tags, List<string> files) { foreach (var file in files) { using ( var fileReader = new FileReader(file)) { _length = fileReader.Length(); var output = string.Empty; var trigger = string.Empty; var bounce = false; var close = false; _currentPosition = 0; while (_length > _currentPosition) { var s = fileReader.ReadString(1); _currentPosition++; if (s == ">") close = true; if (s == "<") { trigger = string.Empty; bounce = false; close = false; } if (!close) { trigger = trigger + s; } if (close) { if (s == ">") { trigger = trigger + s; foreach (var tag in tags) { if (trigger.Contains(tag)) bounce = true; } if (!bounce) { output = output + trigger; } } else { output = output + s; } } } fileReader.Close(); using (var fileWriter = new FileWriter()) { fileWriter.WriteFile(output, file); } } } }