Public feed #721467

Varadhan

public text v1 · immutable
Raw Edit
·published 2007-10-01 08:18 UTC
rendered paste body
		public long Read (long offset, char [] buffer, int offsetInBuffer, int count)
		{
			if (count > this.MaxLength || count > buffer.Length || 
			    count < 0 || ((offsetInBuffer + count) > buffer.Length))
				throw new ArgumentOutOfRangeException ("Parameter name: count");
			
			if (offset < 0 || offset > MaxLength)
				throw new ArgumentOutOfRangeException ("Parameter name: offset");
			
			if (offsetInBuffer < 0 || offsetInBuffer > buffer.Length)
				throw new ArgumentOutOfRangeException ("Parameter name: offsetInBuffer");
			
			if (buffer == null)
				throw new ArgumentNullException ("Parameter name: buffer");

			/*	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 */
			int actualCount = count;
			if (count + offset > this.Length )
				actualCount = this.Length - offset;
			
			Array.Copy (this.buffer, offset, buffer, offsetInBuffer, actualCount);
			
			return actualCount;
		}