private bool TestString(string input, int position, out int testPosition, out MaskedTextResultHint resultHint)
{
Debug.Assert(input != null, "null input.");
Debug.Assert(position >= 0, "Position out of range.");
resultHint = MaskedTextResultHint.Unknown;
testPosition = position;
if (input.Length == 0)
{
return true;
}
// If any char is actually accepted, then the hint is success, otherwise whatever the last character result is.
// Need a temp variable for
MaskedTextResultHint tempHint = resultHint;
foreach (char ch in input)
{
if (testPosition >= _testString.Length)
{
resultHint = MaskedTextResultHint.UnavailableEditPosition;
return false;
}
// If character is not to be escaped, we need to find an edit position to test it in.
if (!TestEscapeChar(ch, testPosition))
{
testPosition = FindEditPositionFrom(testPosition, forward);
if (testPosition == invalidIndex)
{
testPosition = _testString.Length;
resultHint = MaskedTextResultHint.UnavailableEditPosition;
return false;
}
}
// Test/Set char will scape prompt, space and literals if needed.
if (!TestChar(ch, testPosition, out tempHint))
{
resultHint = tempHint;
return false;
}
// Result precedence: Success, SideEffect, NoEffect, CharacterEscaped.
if (tempHint > resultHint)
{
resultHint = tempHint;
}
testPosition++;
}
testPosition--;
return true;
}