Public feed #721540

Varadhan

public text v1 · immutable
Raw Edit
·published 2007-10-01 09:47 UTC
rendered paste body
		public void Write (long offset, char [] buffer, int offsetInBuffer, int count)
		{
			if (count > this.MaxLength || ((count + offset) > this.MaxLength) ||
			    count > buffer.Length || count < 0 || 
			    ((offsetInBuffer + count) > buffer.Length))
				throw new SqlTypeException ("The buffer is insufficient. Read or write operation failed.");
			
			if (offset < 0 || offset > MaxLength)
				throw new ArgumentOutOfRangeException ("offset");
			
			if (offsetInBuffer < 0 || offsetInBuffer > buffer.Length ||
			    offsetInBuffer > this.Length)
				throw new ArgumentOutOfRangeException ("offsetInBuffer");
			
			if (this.IsNull && offsetInBuffer != 0)
				throw new ArgumentOutOfRangeException ("offsetInBuffer");
				
			if (buffer == null)
				throw new ArgumentNullException ("buffer");
			
			long actualCount = count;
			if (count + offset > this.MaxLength)
				actualCount = this.MaxLength - offset;
			
			if (actualCount + offset > this.Length)
				SetLength (actualCount);
			
			Array.Copy (buffer, offsetInBuffer, this.buffer, offset, actualCount);
		}