Author: varadhan
Date: 2007-10-01 14:40:00 -0400 (Mon, 01 Oct 2007)
New Revision: 86719

Modified:
   trunk/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog
   trunk/mcs/class/System.Data/System.Data.SqlTypes/SqlBytes.cs
   trunk/mcs/class/System.Data/System.Data.SqlTypes/SqlChars.cs
Log:
* SqlChars.cs, SqlBytes.cs (Read, Write): Implemented missing 2.0 APIs.

Modified: trunk/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog  2007-10-01 
18:31:24 UTC (rev 86718)
+++ trunk/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog  2007-10-01 
18:40:00 UTC (rev 86719)
@@ -1,3 +1,7 @@
+2007-10-02  Veerapuram Varadhan <[EMAIL PROTECTED]> 
+
+       * SqlChars.cs, SqlBytes.cs (Read, Write): Implemented missing 2.0 APIs.
+
 2007-09-27  Veerapuram Varadhan <[EMAIL PROTECTED]> 
 
        * SqlDecimal.cs, SqlInt32.cs, SqlChars.cs, SqlInt16.cs, SqlInt64.cs,

Modified: trunk/mcs/class/System.Data/System.Data.SqlTypes/SqlBytes.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlTypes/SqlBytes.cs        
2007-10-01 18:31:24 UTC (rev 86718)
+++ trunk/mcs/class/System.Data/System.Data.SqlTypes/SqlBytes.cs        
2007-10-01 18:40:00 UTC (rev 86719)
@@ -249,16 +249,63 @@
                        throw new NotImplementedException ();
                }
 
-               [MonoNotSupported("")]
+               
                public long Read (long offset, byte [] buffer, int 
offsetInBuffer, int count)
                {
-                       throw new NotImplementedException ();
+                       if (buffer == null)
+                               throw new ArgumentNullException ("buffer");
+
+                       if (IsNull)
+                               throw new SqlNullValueException ("There is no 
buffer. Read or write failed");
+                       
+                       if (count > MaxLength || count > buffer.Length || 
+                           count < 0 || ((offsetInBuffer + count) > 
buffer.Length))
+                               throw new ArgumentOutOfRangeException ("count");
+                       
+                       if (offset < 0 || offset > MaxLength)
+                               throw new ArgumentOutOfRangeException 
("offset");
+                       
+                       if (offsetInBuffer < 0 || offsetInBuffer > 
buffer.Length)
+                               throw new ArgumentOutOfRangeException 
("offsetInBuffer");
+                       
+                       /* Final count of what will be copied */
+                       long actualCount = count;
+                       if (count + offset > Length )
+                               actualCount = Length - offset;
+                       
+                       Array.Copy (this.buffer, offset, buffer, 
offsetInBuffer, actualCount);
+                       
+                       return actualCount;
                }
 
-               [MonoNotSupported ("")]
                public void Write (long offset, byte [] buffer, int 
offsetInBuffer, int count)
                {
-                       throw new NotImplementedException ();
+                       if (buffer == null)
+                               throw new ArgumentNullException ("buffer");
+
+                       if (IsNull)
+                               throw new SqlTypeException ("There is no 
buffer. Read or write operation failed.");
+                                                       
+                       if (offset < 0) 
+                               throw new ArgumentOutOfRangeException 
("offset");
+                       
+                       if (offsetInBuffer < 0 || offsetInBuffer > 
buffer.Length 
+                           || offsetInBuffer > Length 
+                           || offsetInBuffer + count > Length
+                           || offsetInBuffer + count > buffer.Length)
+                               throw new ArgumentOutOfRangeException 
("offsetInBuffer");
+                       
+                       if (count < 0 || count > MaxLength)
+                               throw new ArgumentOutOfRangeException ("count");
+                       
+                       if (offset > MaxLength || offset+count > MaxLength)
+                               throw new SqlTypeException ("The buffer is 
insufficient. Read or write operation failed.");
+                       
+                       if (count + offset > Length && 
+                           count + offset <= MaxLength)
+                               SetLength (count);
+                       
+                       Array.Copy (buffer, offsetInBuffer, this.buffer, 
offset, count);
                }
 
                #endregion

Modified: trunk/mcs/class/System.Data/System.Data.SqlTypes/SqlChars.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlTypes/SqlChars.cs        
2007-10-01 18:31:24 UTC (rev 86718)
+++ trunk/mcs/class/System.Data/System.Data.SqlTypes/SqlChars.cs        
2007-10-01 18:40:00 UTC (rev 86719)
@@ -198,16 +198,67 @@
                        }
                }
                                                               
-               [MonoTODO]
                public long Read (long offset, char [] buffer, int 
offsetInBuffer, int count)
                {
-                       throw new NotImplementedException ();
+                       if (buffer == null)
+                               throw new ArgumentNullException ("buffer");
+
+                       if (IsNull)
+                               throw new SqlNullValueException ("There is no 
buffer. Read or write operation failed");
+                       
+                       if (count > MaxLength || count > buffer.Length || 
+                           count < 0 || ((offsetInBuffer + count) > 
buffer.Length))
+                               throw new ArgumentOutOfRangeException ("count");
+                       
+                       if (offset < 0 || offset > MaxLength)
+                               throw new ArgumentOutOfRangeException 
("offset");
+                       
+                       if (offsetInBuffer < 0 || offsetInBuffer > 
buffer.Length)
+                               throw new ArgumentOutOfRangeException 
("offsetInBuffer");
+                       
+                       /*      LAMESPEC: If count specifies more characters 
than what is available from 
+                               offset to the Length of the SqlChars instance, 
only the available 
+                               characters are copied 
+                        */
+                       
+                       /* Final count of what will be copied */
+                       long actualCount = count;
+                       if (count + offset > Length)
+                               actualCount = Length - offset;
+                       
+                       Array.Copy (this.buffer, offset, buffer, 
offsetInBuffer, actualCount);
+                       
+                       return actualCount;
                }
 
-               [MonoNotSupported("")]
                public void Write (long offset, char [] buffer, int 
offsetInBuffer, int count)
                {
-                       throw new NotImplementedException ();
+                       if (buffer == null)
+                               throw new ArgumentNullException ("buffer");
+
+                       if (IsNull)
+                               throw new SqlTypeException ("There is no 
buffer. Read or write operation failed.");
+                                                       
+                       if (offset < 0) 
+                               throw new ArgumentOutOfRangeException 
("offset");
+                       
+                       if (offsetInBuffer < 0 || offsetInBuffer > 
buffer.Length 
+                           || offsetInBuffer > Length 
+                           || offsetInBuffer + count > Length
+                           || offsetInBuffer + count > buffer.Length)
+                               throw new ArgumentOutOfRangeException 
("offsetInBuffer");
+                       
+                       if (count < 0 || count > MaxLength)
+                               throw new ArgumentOutOfRangeException ("count");
+                       
+                       if (offset > MaxLength || offset+count > MaxLength)
+                               throw new SqlTypeException ("The buffer is 
insufficient. Read or write operation failed.");
+                       
+                       if (count + offset > Length && 
+                           count + offset <= MaxLength)
+                               SetLength (count);
+                       
+                       Array.Copy (buffer, offsetInBuffer, this.buffer, 
offset, count);
                }
 
                public static XmlQualifiedName GetXsdType (XmlSchemaSet 
schemaSet)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to