public MyFile(string name, StreamReader reader, ref ColorStaff staff) //formation of file fields for convenient output { this.name = name; main_text = new List <string>(); parseStream(ref reader, ref staff); }
protected List <string> main_text; //text of current file without header and footer protected virtual void parseStream(ref StreamReader reader, ref ColorStaff staff) // take text from stream find and remove header remove footer, save main part { string line; //string for reading stream header_search_flag = false; while ((line = reader.ReadLine()) != footer || (line = reader.ReadLine()) != null) { if (line.Contains(header_indicator_1)) { header_search_flag = true; continue; } if (header_search_flag && line.Contains(header_indicator_2)) { break; } else { staff.CheckLine(line); main_text.Add(line); } } while ((line = reader.ReadLine()) != footer || (line = reader.ReadLine()) != null) { staff.CheckLine(line); main_text.Add(line); } }
private List <MyFile> files; // file class container public FilesSet(string[] names, ref ColorStaff staff) // add information from each file to the equivalent class { files = new List <MyFile>(); Array.Sort(names); files.Add(new MyFirstFile(names[0], new StreamReader(names[0], Encoding.GetEncoding(1251)), ref staff)); for (int i = 1; i < names.Length; i++) { files.Add(new MyFile(names[i], new StreamReader(names[i], Encoding.GetEncoding(1251)), ref staff)); } }
protected override void parseStream(ref StreamReader reader, ref ColorStaff staff) // take text from stream find and remove header remove footer, save main part { string line; while ((line = reader.ReadLine()) != footer || (line = reader.ReadLine()) != null) { staff.CheckLine(line); main_text.Add(line); } }
public MyFirstFile(string name, StreamReader reader, ref ColorStaff staff) : base(name, reader, ref staff) { }