mscorlib(4.0.0.0) API with additions
DecoderReplacementFallbackBuffer.cs
1 using System.Security;
2 
3 namespace System.Text
4 {
7  {
8  private string strDefault;
9 
10  private int fallbackCount = -1;
11 
12  private int fallbackIndex = -1;
13 
16  public override int Remaining
17  {
18  get
19  {
20  if (fallbackCount >= 0)
21  {
22  return fallbackCount;
23  }
24  return 0;
25  }
26  }
27 
31  {
32  strDefault = fallback.DefaultString;
33  }
34 
41  public override bool Fallback(byte[] bytesUnknown, int index)
42  {
43  if (fallbackCount >= 1)
44  {
45  ThrowLastBytesRecursive(bytesUnknown);
46  }
47  if (strDefault.Length == 0)
48  {
49  return false;
50  }
51  fallbackCount = strDefault.Length;
52  fallbackIndex = -1;
53  return true;
54  }
55 
58  public override char GetNextChar()
59  {
60  fallbackCount--;
61  fallbackIndex++;
62  if (fallbackCount < 0)
63  {
64  return '\0';
65  }
66  if (fallbackCount == int.MaxValue)
67  {
68  fallbackCount = -1;
69  return '\0';
70  }
71  return strDefault[fallbackIndex];
72  }
73 
77  public override bool MovePrevious()
78  {
79  if (fallbackCount >= -1 && fallbackIndex >= 0)
80  {
81  fallbackIndex--;
82  fallbackCount++;
83  return true;
84  }
85  return false;
86  }
87 
89  [SecuritySafeCritical]
90  public unsafe override void Reset()
91  {
92  fallbackCount = -1;
93  fallbackIndex = -1;
94  byteStart = null;
95  }
96 
97  [SecurityCritical]
98  internal unsafe override int InternalFallback(byte[] bytes, byte* pBytes)
99  {
100  return strDefault.Length;
101  }
102  }
103 }
override int Remaining
Gets the number of characters in the replacement fallback buffer that remain to be processed.
override char GetNextChar()
Retrieves the next character in the replacement fallback buffer.
Definition: __Canon.cs:3
unsafe override void Reset()
Initializes all internal state information and data in the T:System.Text.DecoderReplacementFallbackBu...
Provides a failure-handling mechanism, called a fallback, for an encoded input byte sequence that can...
Represents a substitute output string that is emitted when the original input byte sequence cannot be...
string DefaultString
Gets the replacement string that is the value of the T:System.Text.DecoderReplacementFallback object.
override bool Fallback(byte[] bytesUnknown, int index)
Prepares the replacement fallback buffer to use the current replacement string.
Provides a buffer that allows a fallback handler to return an alternate string to a decoder when it c...
DecoderReplacementFallbackBuffer(DecoderReplacementFallback fallback)
Initializes a new instance of the T:System.Text.DecoderReplacementFallbackBuffer class using the valu...
override bool MovePrevious()
Causes the next call to M:System.Text.DecoderReplacementFallbackBuffer.GetNextChar to access the char...