System.Text.DecoderReplacementFallbackBuffer.GetNextChar C# (CSharp) Method

GetNextChar() public method

public GetNextChar ( ) : char
return char
        public override char GetNextChar()
        {
            // We want it to get < 0 because == 0 means that the current/last character is a fallback
            // and we need to detect recursion.  We could have a flag but we already have this counter.
            fallbackCount--;
            fallbackIndex++;

            // Do we have anything left? 0 is now last fallback char, negative is nothing left
            if (fallbackCount < 0)
                return (char)0;

            // Need to get it out of the buffer.
            BCLDebug.Assert(fallbackIndex < strDefault.Length && fallbackIndex >= 0,
                            "Index exceeds buffer range");
            return strDefault[fallbackIndex];
        }

Usage Example

示例#1
0
        public void FallbackEmptyDefault()
        {
            Buffer b = NewInstance();

            Assert.IsTrue(b.Fallback(new byte [] {}, 0), "#0");
            Assert.IsFalse(b.MovePrevious(), "#1");
            Assert.AreEqual(1, b.Remaining, "#2");
            Assert.AreEqual('?', b.GetNextChar(), "#3");
            Assert.AreEqual(0, b.Remaining, "#4");
            // the string is already consumed.
            Assert.AreEqual(char.MinValue, b.GetNextChar(), "#5");
        }
All Usage Examples Of System.Text.DecoderReplacementFallbackBuffer::GetNextChar