mscorlib(4.0.0.0) API with additions
EncoderReplacementFallback.cs
1 namespace System.Text
2 {
5  [__DynamicallyInvokable]
7  {
8  private string strDefault;
9 
12  [__DynamicallyInvokable]
13  public string DefaultString
14  {
15  [__DynamicallyInvokable]
16  get
17  {
18  return strDefault;
19  }
20  }
21 
24  [__DynamicallyInvokable]
25  public override int MaxCharCount
26  {
27  [__DynamicallyInvokable]
28  get
29  {
30  return strDefault.Length;
31  }
32  }
33 
35  [__DynamicallyInvokable]
37  : this("?")
38  {
39  }
40 
47  [__DynamicallyInvokable]
48  public EncoderReplacementFallback(string replacement)
49  {
50  if (replacement == null)
51  {
52  throw new ArgumentNullException("replacement");
53  }
54  bool flag = false;
55  for (int i = 0; i < replacement.Length; i++)
56  {
57  if (char.IsSurrogate(replacement, i))
58  {
59  if (char.IsHighSurrogate(replacement, i))
60  {
61  if (flag)
62  {
63  break;
64  }
65  flag = true;
66  continue;
67  }
68  if (!flag)
69  {
70  flag = true;
71  break;
72  }
73  flag = false;
74  }
75  else if (flag)
76  {
77  break;
78  }
79  }
80  if (flag)
81  {
82  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex", "replacement"));
83  }
84  strDefault = replacement;
85  }
86 
89  [__DynamicallyInvokable]
91  {
92  return new EncoderReplacementFallbackBuffer(this);
93  }
94 
99  [__DynamicallyInvokable]
100  public override bool Equals(object value)
101  {
102  EncoderReplacementFallback encoderReplacementFallback = value as EncoderReplacementFallback;
103  if (encoderReplacementFallback != null)
104  {
105  return strDefault == encoderReplacementFallback.strDefault;
106  }
107  return false;
108  }
109 
112  [__DynamicallyInvokable]
113  public override int GetHashCode()
114  {
115  return strDefault.GetHashCode();
116  }
117  }
118 }
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
override EncoderFallbackBuffer CreateFallbackBuffer()
Creates a T:System.Text.EncoderFallbackBuffer object that is initialized with the replacement string ...
EncoderReplacementFallback()
Initializes a new instance of the T:System.Text.EncoderReplacementFallback class.
override int GetHashCode()
Retrieves the hash code for the value of the T:System.Text.EncoderReplacementFallback object.
Provides a failure-handling mechanism, called a fallback, for an input character that cannot be conve...
override bool Equals(object value)
Indicates whether the value of a specified object is equal to the T:System.Text.EncoderReplacementFal...
Provides a failure handling mechanism, called a fallback, for an input character that cannot be conve...
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
string DefaultString
Gets the replacement string that is the value of the T:System.Text.EncoderReplacementFallback object.
EncoderReplacementFallback(string replacement)
Initializes a new instance of the T:System.Text.EncoderReplacementFallback class using a specified re...
The exception that is thrown when one of the arguments provided to a method is not valid.
override int MaxCharCount
Gets the number of characters in the replacement string for the T:System.Text.EncoderReplacementFallb...
Provides a buffer that allows a fallback handler to return an alternate string to an encoder when it ...
Specifies that the class can be serialized.
Represents a substitute input string that is used when the original input character cannot be encoded...