本文整理汇总了C#中ITypedSettersV3.SetCharsLength方法的典型用法代码示例。如果您正苦于以下问题:C# ITypedSettersV3.SetCharsLength方法的具体用法?C# ITypedSettersV3.SetCharsLength怎么用?C# ITypedSettersV3.SetCharsLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypedSettersV3
的用法示例。
在下文中一共展示了ITypedSettersV3.SetCharsLength方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetSqlChars_Unchecked
private static void SetSqlChars_Unchecked( SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SqlChars value, int offset, int length ) {
if ( value.IsNull ) {
setters.SetDBNull( sink, ordinal );
sink.ProcessMessagesAndThrow();
}
else {
int chunkSize;
if ( length > __maxCharChunkSize || length < 0 ) {
chunkSize = __maxCharChunkSize;
}
else {
chunkSize = checked( (int)length );
}
char[] buffer = new char[ chunkSize ];
long charsRead;
long charsWritten = 1; // prime value to get into write loop
long currentOffset = offset;
long lengthWritten = 0;
while ( (length < 0 || lengthWritten < length) &&
0 != ( charsRead = value.Read( currentOffset, buffer, 0, chunkSize ) ) &&
0 != charsWritten ) {
charsWritten = setters.SetChars( sink, ordinal, currentOffset, buffer, 0, checked( (int) charsRead ) );
sink.ProcessMessagesAndThrow();
checked{ currentOffset += charsWritten; }
checked{ lengthWritten += charsWritten;}
}
// Make sure to trim any left-over data
setters.SetCharsLength( sink, ordinal, currentOffset );
sink.ProcessMessagesAndThrow();
}
}
示例2: SetCharArray_Unchecked
private static void SetCharArray_Unchecked( SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, char[] buffer, int bufferOffset, int length ) {
if ( length > 0 ) {
setters.SetChars( sink, ordinal, 0, buffer, bufferOffset, length );
sink.ProcessMessagesAndThrow();
}
setters.SetCharsLength( sink, ordinal, length );
sink.ProcessMessagesAndThrow();
}
示例3: SetTextReader_Unchecked
private static void SetTextReader_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SmiMetaData metadata, TextDataFeed feed) {
long len = metadata.MaxLength;
char[] buff = new char[constTextBufferSize];
int nWritten = 0;
do {
int nRead = 0;
int readSize = constTextBufferSize;
if (len > 0 && nWritten + readSize > len) {
readSize = (int)(len - nWritten);
}
Debug.Assert(readSize >= 0);
nRead = feed._source.Read(buff, 0, readSize);
if (nRead == 0) {
break;
}
setters.SetChars(sink, ordinal, nWritten, buff, 0, nRead);
sink.ProcessMessagesAndThrow();
nWritten += nRead;
} while (len <= 0 || nWritten < len);
setters.SetCharsLength(sink, ordinal, nWritten);
sink.ProcessMessagesAndThrow();
}
示例4: SetChars_FromRecord
private static void SetChars_FromRecord( SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SmiMetaData metaData, SqlDataRecord record, int offset ) {
int length = 0;
// Deal with large values by sending bufferLength of NoLengthLimit
// CheckXetParameters will ignore length checks in this case
long bufferLength = record.GetChars(ordinal, 0, null, 0, 0);
if ( bufferLength > Int32.MaxValue ) {
bufferLength = NoLengthLimit;
}
length = CheckXetParameters( metaData.SqlDbType, metaData.MaxLength, NoLengthLimit /* actual */, 0, checked( (int) bufferLength ), offset, checked( (int) bufferLength - offset ) );
int chunkSize;
if ( length > __maxCharChunkSize || length < 0 ) {
if (MetaDataUtilsSmi.IsAnsiType(metaData.SqlDbType)) {
chunkSize = __maxByteChunkSize;
} else {
chunkSize = __maxCharChunkSize;
}
}
else {
chunkSize = checked( (int)length );
}
char[] buffer = new char[ chunkSize ];
long charsRead;
long charsWritten = 1; // prime value to get into write loop
long currentOffset = offset;
long lengthWritten = 0;
while ( (length < 0 || lengthWritten < length) &&
0 != ( charsRead = record.GetChars( ordinal, currentOffset, buffer, 0, chunkSize ) ) &&
0 != charsWritten ) {
charsWritten = setters.SetChars( sink, ordinal, currentOffset, buffer, 0, checked( (int) charsRead ) );
sink.ProcessMessagesAndThrow();
checked{ currentOffset += charsWritten; }
checked{ lengthWritten += charsWritten;}
}
// Make sure to trim any left-over data
setters.SetCharsLength( sink, ordinal, currentOffset );
sink.ProcessMessagesAndThrow();
}
示例5: SetSqlChars_Unchecked
private static void SetSqlChars_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SqlChars value, int offset, int length)
{
if (value.IsNull)
{
setters.SetDBNull(sink, ordinal);
sink.ProcessMessagesAndThrow();
}
else
{
int num4;
long num5;
if ((length > 0xfa0) || (length < 0))
{
num4 = 0xfa0;
}
else
{
num4 = length;
}
char[] buffer = new char[num4];
long num2 = 1L;
long num = offset;
for (long i = 0L; ((length < 0) || (i < length)) && ((0L != (num5 = value.Read(num, buffer, 0, num4))) && (0L != num2)); i += num2)
{
num2 = setters.SetChars(sink, ordinal, num, buffer, 0, (int) num5);
sink.ProcessMessagesAndThrow();
num += num2;
}
setters.SetCharsLength(sink, ordinal, num);
sink.ProcessMessagesAndThrow();
}
}
示例6: SetChars_FromRecord
private static void SetChars_FromRecord(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SmiMetaData metaData, SqlDataRecord record, int offset)
{
int num4;
long num7;
int num = 0;
long num5 = record.GetChars(ordinal, 0L, null, 0, 0);
if (num5 > 0x7fffffffL)
{
num5 = -1L;
}
num = CheckXetParameters(metaData.SqlDbType, metaData.MaxLength, -1L, 0L, (int) num5, offset, ((int) num5) - offset);
if ((num > 0xfa0) || (num < 0))
{
if (MetaDataUtilsSmi.IsAnsiType(metaData.SqlDbType))
{
num4 = 0x1f40;
}
else
{
num4 = 0xfa0;
}
}
else
{
num4 = num;
}
char[] buffer = new char[num4];
long num3 = 1L;
long fieldOffset = offset;
for (long i = 0L; ((num < 0) || (i < num)) && ((0L != (num7 = record.GetChars(ordinal, fieldOffset, buffer, 0, num4))) && (0L != num3)); i += num3)
{
num3 = setters.SetChars(sink, ordinal, fieldOffset, buffer, 0, (int) num7);
sink.ProcessMessagesAndThrow();
fieldOffset += num3;
}
setters.SetCharsLength(sink, ordinal, fieldOffset);
sink.ProcessMessagesAndThrow();
}