ソースを参照

* SqlChars.cs, SqlBytes.cs (Read, Write): Implemented missing 2.0 APIs.

svn path=/trunk/mcs/; revision=86719
Veerapuram Varadhan 18 年 前
コミット
1b558f4efe

+ 4 - 0
mcs/class/System.Data/System.Data.SqlTypes/ChangeLog

@@ -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,

+ 51 - 4
mcs/class/System.Data/System.Data.SqlTypes/SqlBytes.cs

@@ -249,16 +249,63 @@ namespace System.Data.SqlTypes
 			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

+ 55 - 4
mcs/class/System.Data/System.Data.SqlTypes/SqlChars.cs

@@ -198,16 +198,67 @@ namespace System.Data.SqlTypes
 			}
 		}
                                                               
-		[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)