当前位置: 首页>>代码示例>>C#>>正文


C# SqlBytes.Read方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:35,代码来源:ValueUtilsSmi.cs

示例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");
		            });
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:12,代码来源:SqlBytesTest.cs

示例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");
		            });
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:13,代码来源:SqlBytesTest.cs

示例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");
		            });
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:12,代码来源:SqlBytesTest.cs

示例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");
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:10,代码来源:SqlBytesTest.cs

示例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");
		            });
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:13,代码来源:SqlBytesTest.cs

示例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");
		            });
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:13,代码来源:SqlBytesTest.cs

示例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");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:SqlBytesTest.cs

示例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");
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:9,代码来源:SqlBytesTest.cs

示例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();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:ValueUtilsSmi.cs

示例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");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:SqlBytesTest.cs

示例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));
        }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:SqlBytesTest.cs

示例13: Read_NullBufferAndInstanceValueTest

        public void Read_NullBufferAndInstanceValueTest()
        {
            byte[] b2 = null;
            SqlBytes bytes = new SqlBytes();

            Assert.Throws<SqlNullValueException>(() => bytes.Read(0, b2, 8, 4));
        }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:SqlBytesTest.cs

示例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));
        }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:SqlBytesTest.cs

示例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));
        }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:SqlBytesTest.cs


注:本文中的System.Data.SqlTypes.SqlBytes.Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。