SIL.FieldWorks.UnicodeCharEditor.PUAInstaller.ReadToEndOfSection C# (CSharp) Method

ReadToEndOfSection() private static method

Read to the end of a given section of matching bidi class values. Passes everything read through to the writer. If this finds a section count comment, it will replace it with the current count.
private static ReadToEndOfSection ( TextReader reader, TextWriter writer, string lastProperty, int currentCount, IUcdCharacter ucdCharacter ) : string
reader TextReader The reader to read through.
writer System.IO.TextWriter
lastProperty string The section we need to reed to the end of.
currentCount int The count of characters found before reading to the end of the section.
ucdCharacter IUcdCharacter UCD Character used to know what kind of UCD file we are parsing. /// The actual contencts of the UCD Character are ignored.
return string
		private static string ReadToEndOfSection(TextReader reader, TextWriter writer, string lastProperty, int currentCount, IUcdCharacter ucdCharacter)
		{
			string line;
			while ((line = reader.ReadLine()) != null)
			{
				// if there is a bidi class value to read
				if (HasBidiData(line))
				{
					// increments the current count of codepoints found so far.
					IncrementCount(ref currentCount, line);

					// read the bidi value from the line
					var currentProperty = GetProperty(line);

					// if it isn't in the current section we are done with section.
					if (!ucdCharacter.SameRegion(currentProperty, lastProperty))
						break;
				}
				// if its a comment, find the total count comment and replace it with the current count.
				else if (line.ToLowerInvariant().IndexOf("total code points") != -1)
				{
					line = "# Total code points: " + currentCount;
					currentCount = 0;
				}
				// Write through all lines except the first line of the next section
				writer.WriteLine(line);
			}

			// Return the last line that we read
			// This is the first line of the next section, so someone will probably want to parse it.
			return line;
		}