private void WriteBidiCodepointBlock(TextWriter writer, string originalBeginningCode, string originalEndCode,
List<IUcdCharacter> codepointsWithinRange,
string generalCategory, string firstName, string lastName, bool add)
{
//Allows us to store the original end and beginning code points while looping
//through them
var beginningCode = originalBeginningCode;
var endCode = originalEndCode;
//Write each entry
foreach (var ucdCharacter in codepointsWithinRange)
{
//If the current xmlCodepoint is the same as the beginning codepoint
if (ucdCharacter.CompareTo(beginningCode) == 0)
{
//Shift the beginning down one
beginningCode = AddHex(beginningCode, 1);
//Add or delete the character
AddUCDLine(writer, ucdCharacter, add);
}
//If the current xmlCodepoint is between the beginning and end
else if (ucdCharacter.CompareTo(endCode) != 0)
{
if (originalBeginningCode == beginningCode)
{
//We're writing a range block below the current xmlCodepoint
WriteBidiRange(writer, beginningCode,
AddHex(ucdCharacter.CodePoint, -1),
generalCategory, firstName, "???", ucdCharacter.Property);
}
else
{
//We're writing a range block below the current xmlCodepoint
WriteBidiRange(writer, beginningCode,
AddHex(ucdCharacter.CodePoint, -1),
generalCategory, "???", "???", ucdCharacter.Property);
}
AddUCDLine(writer, ucdCharacter, add);
//Set the beginning code to be right after the ucdCharacterthat we just added
beginningCode = AddHex(ucdCharacter.CodePoint, 1);
}
//If the current xmlCodepoint is the same as the end codepoint
else
{
//Moves the end down a codepoint address
endCode = AddHex(endCode, -1);
//Write our range of data
WriteBidiRange(writer, beginningCode, endCode, generalCategory, "???", "???",
ucdCharacter.Property);
//Writes the current line
AddUCDLine(writer, ucdCharacter, add);
return;
}
}
//Write our range of data
WriteBidiRange(writer, beginningCode, endCode, generalCategory, "???", lastName,
codepointsWithinRange[0].Property);
}