[System.Runtime.InteropServices.ComVisible(false)]
public override unsafe int GetByteCount(char* chars, int count)
{
- // Validate Parameters
- if (chars == null)
- throw new ArgumentNullException("chars",
- Environment.GetResourceString("ArgumentNull_Array"));
-
- if (count < 0)
- throw new ArgumentOutOfRangeException("count",
- Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- Contract.EndContractBlock();
-
- // Call it with empty encoder
- return GetByteCount(chars, count, null);
+ return EncodingForwarder.GetByteCount(this, chars, count);
}
// Parent method is safe.
public unsafe static int GetByteCount(Encoding encoding, string s)
{
+ Contract.Assert(encoding != null);
if (s == null)
{
throw new ArgumentNullException("s");
fixed (char* pChars = s)
return encoding.GetByteCount(pChars, s.Length, encoder: null);
}
+
+ public unsafe static int GetByteCount(Encoding encoding, char* chars, int count)
+ {
+ Contract.Assert(encoding != null);
+ if (chars == null)
+ {
+ throw new ArgumentNullException("chars", Environment.GetResourceString("ArgumentNull_Array"));
+ }
+ if (count < 0)
+ {
+ throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ }
+ Contract.EndContractBlock();
+
+ // Call the internal version, with an empty encoder
+ return encoding.GetByteCount(chars, count, encoder: null);
+ }
}
}
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetByteCount(char* chars, int count)
{
- // Validate Parameters
- if (chars == null)
- throw new ArgumentNullException("chars",
- Environment.GetResourceString("ArgumentNull_Array"));
-
- if (count < 0)
- throw new ArgumentOutOfRangeException("count",
- Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- Contract.EndContractBlock();
-
- // Call it with empty encoder
- return GetByteCount(chars, count, null);
+ return EncodingForwarder.GetByteCount(this, chars, count);
}
// Parent method is safe.
[CLSCompliant(false)]
public override unsafe int GetByteCount(char* chars, int count)
{
- // Validate Parameters
- if (chars == null)
- throw new ArgumentNullException("chars",
- Environment.GetResourceString("ArgumentNull_Array"));
-
- if (count < 0)
- throw new ArgumentOutOfRangeException("count",
- Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- Contract.EndContractBlock();
-
- // Call it with empty encoder
- return GetByteCount(chars, count, null);
+ return EncodingForwarder.GetByteCount(this, chars, count);
}
// Parent method is safe.
[System.Runtime.InteropServices.ComVisible(false)]
public override unsafe int GetByteCount(char* chars, int count)
{
- // Validate Parameters
- if (chars == null)
- throw new ArgumentNullException("chars",
- Environment.GetResourceString("ArgumentNull_Array"));
-
- if (count < 0)
- throw new ArgumentOutOfRangeException("count",
- Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- Contract.EndContractBlock();
-
- // Call it with empty encoder
- return GetByteCount(chars, count, null);
+ return EncodingForwarder.GetByteCount(this, chars, count);
}
// Parent method is safe.
[System.Runtime.InteropServices.ComVisible(false)]
public override unsafe int GetByteCount(char* chars, int count)
{
- // Validate Parameters
- if (chars == null)
- throw new ArgumentNullException("chars",
- Environment.GetResourceString("ArgumentNull_Array"));
-
- if (count < 0)
- throw new ArgumentOutOfRangeException("count",
- Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- Contract.EndContractBlock();
-
- // Call it with empty encoder
- return GetByteCount(chars, count, null);
+ return EncodingForwarder.GetByteCount(this, chars, count);
}
// Parent method is safe.
[System.Runtime.InteropServices.ComVisible(false)]
public override unsafe int GetByteCount(char* chars, int count)
{
- // Validate Parameters
- if (chars == null)
- throw new ArgumentNullException("chars",
- Environment.GetResourceString("ArgumentNull_Array"));
-
- if (count < 0)
- throw new ArgumentOutOfRangeException("count",
- Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- Contract.EndContractBlock();
-
- // Call it with empty encoder
- return GetByteCount(chars, count, null);
+ return EncodingForwarder.GetByteCount(this, chars, count);
}
// Parent method is safe.