using System.Runtime.InteropServices;
[Serializable]
+[ComVisible (true)]
public abstract class Decoder
{
// Constructor.
protected Decoder () {}
-#if NET_2_0
DecoderFallback fallback = new DecoderReplacementFallback ();
DecoderFallbackBuffer fallback_buffer;
+ [ComVisible (false)]
public DecoderFallback Fallback {
get { return fallback; }
set {
}
}
+ [ComVisible (false)]
public DecoderFallbackBuffer FallbackBuffer {
get {
if (fallback_buffer == null)
return fallback_buffer;
}
}
-#endif
// Get the number of characters needed to decode a buffer.
public abstract int GetCharCount (byte[] bytes, int index, int count);
public abstract int GetChars (byte[] bytes, int byteIndex, int byteCount,
char[] chars, int charIndex);
-#if NET_2_0
+ [ComVisible (false)]
public virtual int GetCharCount (byte [] bytes, int index, int count, bool flush)
{
if (flush)
}
[CLSCompliant (false)]
+ [ComVisible (false)]
public unsafe virtual int GetCharCount (byte* bytes, int count, bool flush)
{
if (bytes == null)
}
[CLSCompliant (false)]
+ [ComVisible (false)]
public unsafe virtual int GetChars (byte* bytes, int byteCount,
char* chars, int charCount, bool flush)
{
CheckArguments (chars, charCount, bytes, byteCount);
char [] carr = new char [charCount];
- Marshal.Copy ((IntPtr) chars, carr, 0, charCount);
byte [] barr = new byte [byteCount];
Marshal.Copy ((IntPtr) bytes, barr, 0, byteCount);
- return GetChars (barr, 0, byteCount, carr, 0, flush);
+ int charsUsed = GetChars (barr, 0, byteCount, carr, 0, flush);
+ Marshal.Copy (carr, 0, (IntPtr) chars, charsUsed);
+ return charsUsed;
}
+ [ComVisible (false)]
public virtual void Reset ()
{
if (fallback_buffer != null)
}
[CLSCompliant (false)]
+ [ComVisible (false)]
public unsafe virtual void Convert (
byte* bytes, int byteCount,
char* chars, int charCount, bool flush,
charsUsed = GetChars (bytes, bytesUsed, chars, charCount, flush);
}
+ [ComVisible (false)]
public virtual void Convert (
byte [] bytes, int byteIndex, int byteCount,
char [] chars, int charIndex, int charCount, bool flush,
out int bytesUsed, out int charsUsed, out bool completed)
{
CheckArguments (bytes, byteIndex, byteCount);
- CheckArguments (chars, charIndex);
+ if (chars == null)
+ throw new ArgumentNullException ("chars");
+ if (charIndex < 0)
+ throw new ArgumentOutOfRangeException ("charIndex");
if (charCount < 0 || chars.Length < charIndex + charCount)
throw new ArgumentOutOfRangeException ("charCount");
{
if (chars == null)
throw new ArgumentNullException ("chars");
- if (charIndex < 0 || chars.Length <= charIndex)
+ if (charIndex < 0 || chars.Length < charIndex)
throw new ArgumentOutOfRangeException ("charIndex");
}
{
if (bytes == null)
throw new ArgumentNullException ("bytes");
- if (byteIndex < 0 || bytes.Length <= byteIndex)
+ if (byteIndex < 0)
throw new ArgumentOutOfRangeException ("byteIndex");
if (byteCount < 0 || bytes.Length < byteIndex + byteCount)
throw new ArgumentOutOfRangeException ("byteCount");
if (byteCount < 0)
throw new ArgumentOutOfRangeException ("byteCount");
}
-#endif
-
}; // class Decoder
}; // namespace System.Text