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


C# TdsParserStateObject.ReadPlpBytesChunk方法代码示例

本文整理汇总了C#中System.Data.SqlClient.TdsParserStateObject.ReadPlpBytesChunk方法的典型用法代码示例。如果您正苦于以下问题:C# TdsParserStateObject.ReadPlpBytesChunk方法的具体用法?C# TdsParserStateObject.ReadPlpBytesChunk怎么用?C# TdsParserStateObject.ReadPlpBytesChunk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SqlClient.TdsParserStateObject的用法示例。


在下文中一共展示了TdsParserStateObject.ReadPlpBytesChunk方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadPlpAnsiChars

        internal int ReadPlpAnsiChars(ref char[] buff, int offst, int len, SqlMetaDataPriv metadata, TdsParserStateObject stateObj)
        {
            int charsRead = 0;
            int charsLeft = 0;
            int bytesRead = 0;
            int totalcharsRead = 0;

            if (stateObj._longlen == 0)
            {
                Debug.Assert(stateObj._longlenleft == 0);
                return 0;       // No data
            }

            Debug.Assert(((ulong)stateObj._longlen != TdsEnums.SQL_PLP_NULL),
                    "Out of sync plp read request");

            Debug.Assert((buff == null && offst == 0) || (buff.Length >= offst + len), "Invalid length sent to ReadPlpAnsiChars()!");
            charsLeft = len;

            if (stateObj._longlenleft == 0)
            {
                stateObj.ReadPlpLength(false);
                if (stateObj._longlenleft == 0)
                {// Data read complete
                    stateObj._plpdecoder = null;
                    return 0;
                }
            }

            if (stateObj._plpdecoder == null)
            {
                Encoding enc = metadata.encoding;

                if (enc == null)
                {
                    if (null == _defaultEncoding)
                    {
                        ThrowUnsupportedCollationEncountered(stateObj);
                    }

                    enc = _defaultEncoding;
                }
                stateObj._plpdecoder = enc.GetDecoder();
            }

            while (charsLeft > 0)
            {
                bytesRead = (int)Math.Min(stateObj._longlenleft, (ulong)charsLeft);
                if ((stateObj._bTmp == null) || (stateObj._bTmp.Length < bytesRead))
                {
                    // Grow the array
                    stateObj._bTmp = new byte[bytesRead];
                }

                bytesRead = stateObj.ReadPlpBytesChunk(stateObj._bTmp, 0, bytesRead);

                charsRead = stateObj._plpdecoder.GetChars(stateObj._bTmp, 0, bytesRead, buff, offst);
                charsLeft -= charsRead;
                offst += charsRead;
                totalcharsRead += charsRead;
                if (stateObj._longlenleft == 0)  // Read the next chunk or cleanup state if hit the end
                    stateObj.ReadPlpLength(false);

                if (stateObj._longlenleft == 0)
                { // Data read complete
                    stateObj._plpdecoder = null;
                    break;
                }
            }
            return (totalcharsRead);
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:71,代码来源:TdsParser.cs

示例2: ReadPlpAnsiChars

 internal int ReadPlpAnsiChars(ref char[] buff, int offst, int len, SqlMetaDataPriv metadata, TdsParserStateObject stateObj)
 {
     int num3 = 0;
     int num2 = 0;
     int num = 0;
     int num4 = 0;
     if (stateObj._longlen == 0L)
     {
         return 0;
     }
     num2 = len;
     if (stateObj._longlenleft == 0L)
     {
         stateObj.ReadPlpLength(false);
         if (stateObj._longlenleft == 0L)
         {
             return 0;
         }
     }
     Encoding encoding = metadata.encoding;
     if (encoding == null)
     {
         if (this._defaultEncoding == null)
         {
             this.ThrowUnsupportedCollationEncountered(stateObj);
         }
         encoding = this._defaultEncoding;
     }
     while (num2 > 0)
     {
         num = (int) Math.Min(stateObj._longlenleft, (ulong) num2);
         if ((stateObj._bTmp == null) || (stateObj._bTmp.Length < num))
         {
             stateObj._bTmp = new byte[num];
         }
         num = stateObj.ReadPlpBytesChunk(stateObj._bTmp, 0, num);
         num3 = encoding.GetChars(stateObj._bTmp, 0, num, buff, offst);
         num2 -= num3;
         offst += num3;
         num4 += num3;
         if (stateObj._longlenleft == 0L)
         {
             stateObj.ReadPlpLength(false);
         }
         if (stateObj._longlenleft == 0L)
         {
             return num4;
         }
     }
     return num4;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:51,代码来源:TdsParser.cs


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