本文整理汇总了C#中System.Data.SqlTypes.SqlBytes.Read方法的典型用法代码示例。如果您正苦于以下问题:C# SqlBytes.Read方法的具体用法?C# SqlBytes.Read怎么用?C# SqlBytes.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlTypes.SqlBytes
的用法示例。
在下文中一共展示了SqlBytes.Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetSqlBytes_Unchecked
// note: length < 0 indicates write everything
private static void SetSqlBytes_Unchecked( SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SqlBytes value, int offset, long length ) {
if ( value.IsNull ) {
setters.SetDBNull( sink, ordinal );
sink.ProcessMessagesAndThrow();
}
else {
int chunkSize;
if ( length > __maxByteChunkSize || length < 0 ) {
chunkSize = __maxByteChunkSize;
}
else {
chunkSize = checked( (int)length );
}
byte[] buffer = new byte[ chunkSize ];
long bytesRead;
long bytesWritten = 1; // prime value to get into write loop
long currentOffset = offset;
long lengthWritten = 0;
while ( (length < 0 || lengthWritten < length) &&
0 != ( bytesRead = value.Read( currentOffset, buffer, 0, chunkSize ) ) &&
0 != bytesWritten ) {
bytesWritten = setters.SetBytes( sink, ordinal, currentOffset, buffer, 0, checked( (int) bytesRead ) );
sink.ProcessMessagesAndThrow();
checked{ currentOffset += bytesWritten; }
checked{ lengthWritten += bytesWritten; }
}
// Make sure to trim any left-over data
setters.SetBytesLength( sink, ordinal, currentOffset );
sink.ProcessMessagesAndThrow();
}
}
示例2: Read_NullBufferAndInstanceValueTest
public void Read_NullBufferAndInstanceValueTest ()
{
ExceptionAssert.Throws<ArgumentNullException>(
delegate
{
byte [] b2 = null;
SqlBytes bytes = new SqlBytes ();
bytes.Read (0, b2, 8, 4);
Assert.Fail ("#10 Should throw ArgumentNullException");
});
}
示例3: Read_InvalidCountTest2
public void Read_InvalidCountTest2 ()
{
ExceptionAssert.Throws<ArgumentOutOfRangeException>(
delegate
{
byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
SqlBytes bytes = new SqlBytes (b1);
byte [] b2 = new byte [5];
bytes.Read (0, b2, 3, 4);
Assert.Fail ("#12 Should throw ArgumentOutOfRangeException");
});
}
示例4: Read_NullInstanceValueTest
public void Read_NullInstanceValueTest ()
{
ExceptionAssert.Throws<SqlNullValueException>(
delegate
{
byte [] b2 = new byte [5];
SqlBytes bytes = new SqlBytes ();
bytes.Read (0, b2, 8, 4);
Assert.Fail ("#7 Should throw SqlNullValueException");
});
}
示例5: Read_SuccessTest2
public void Read_SuccessTest2 ()
{
byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
SqlBytes bytes = new SqlBytes (b1);
byte [] b2 = new byte [10];
bytes.Read (5, b2, 0, 10);
Assert.AreEqual (bytes.Value [5], b2 [0], "#8 Should be same");
Assert.AreEqual (bytes.Value [9], b2 [4], "#9 Should be same");
}
示例6: Read_NullBufferTest
public void Read_NullBufferTest ()
{
ExceptionAssert.Throws<ArgumentNullException>(
delegate
{
byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
SqlBytes bytes = new SqlBytes (b1);
byte [] b2 = null;
bytes.Read (0, b2, 0, 10);
Assert.Fail ("#2 Should throw ArgumentNullException");
});
}
示例7: Read_NegativeOffsetInBufferTest
public void Read_NegativeOffsetInBufferTest ()
{
ExceptionAssert.Throws<ArgumentOutOfRangeException>(
delegate
{
byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
SqlBytes bytes = new SqlBytes (b1);
byte [] b2 = new byte [5];
bytes.Read (0, b2, -1, 4);
Assert.Fail ("#5 Should throw ArgumentOutOfRangeException");
});
}
示例8: Read_NegativeCountTest
public void Read_NegativeCountTest ()
{
byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
SqlBytes bytes = new SqlBytes (b1);
byte [] b2 = new byte [5];
bytes.Read (0, b2, 0, -1);
Assert.Fail ("#11 Should throw ArgumentOutOfRangeException");
}
示例9: Read_SuccessTest1
public void Read_SuccessTest1 ()
{
byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
SqlBytes bytes = new SqlBytes (b1);
byte [] b2 = new byte [10];
bytes.Read (0, b2, 0, (int) bytes.Length);
Assert.AreEqual (bytes.Value [5], b2 [5], "#1 Should be equal");
}
示例10: SetSqlBytes_Unchecked
private static void SetSqlBytes_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SqlBytes value, int offset, long length)
{
if (value.IsNull)
{
setters.SetDBNull(sink, ordinal);
sink.ProcessMessagesAndThrow();
}
else
{
int num4;
long num5;
if ((length > 0x1f40L) || (length < 0L))
{
num4 = 0x1f40;
}
else
{
num4 = (int) length;
}
byte[] buffer = new byte[num4];
long num2 = 1L;
long num = offset;
for (long i = 0L; ((length < 0L) || (i < length)) && ((0L != (num5 = value.Read(num, buffer, 0, num4))) && (0L != num2)); i += num2)
{
num2 = setters.SetBytes(sink, ordinal, num, buffer, 0, (int) num5);
sink.ProcessMessagesAndThrow();
num += num2;
}
setters.SetBytesLength(sink, ordinal, num);
sink.ProcessMessagesAndThrow();
}
}
示例11: Read_InvalidOffsetInBufferTest
public void Read_InvalidOffsetInBufferTest ()
{
byte [] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
SqlBytes bytes = new SqlBytes (b1);
byte [] b2 = new byte [5];
bytes.Read (0, b2, 8, 4);
Assert.Fail ("#6 Should throw ArgumentOutOfRangeException");
}
示例12: Read_InvalidCountTest2
public void Read_InvalidCountTest2()
{
byte[] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
SqlBytes bytes = new SqlBytes(b1);
byte[] b2 = new byte[5];
Assert.Throws<ArgumentOutOfRangeException>(() => bytes.Read(0, b2, 3, 4));
}
示例13: Read_NullBufferAndInstanceValueTest
public void Read_NullBufferAndInstanceValueTest()
{
byte[] b2 = null;
SqlBytes bytes = new SqlBytes();
Assert.Throws<SqlNullValueException>(() => bytes.Read(0, b2, 8, 4));
}
示例14: Read_NegativeOffsetInBufferTest
public void Read_NegativeOffsetInBufferTest()
{
byte[] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
SqlBytes bytes = new SqlBytes(b1);
byte[] b2 = new byte[5];
Assert.Throws<ArgumentOutOfRangeException>(() => bytes.Read(0, b2, -1, 4));
}
示例15: Read_NullBufferTest
public void Read_NullBufferTest()
{
byte[] b1 = { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
SqlBytes bytes = new SqlBytes(b1);
byte[] b2 = null;
Assert.Throws<ArgumentNullException>(() => bytes.Read(0, b2, 0, 10));
}