本文整理汇总了C#中ReadState.Continue方法的典型用法代码示例。如果您正苦于以下问题:C# ReadState.Continue方法的具体用法?C# ReadState.Continue怎么用?C# ReadState.Continue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadState
的用法示例。
在下文中一共展示了ReadState.Continue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
private static void Read(ReadState state)
{
Bytes data = state.GetRecordData();
bool compressed = (state.OptionsFlags & 0x01) == 0;
ushort bytesAvailable = (ushort)(data.Length - state.Offset);
ushort bytesToRead;
if (state.CharactersRead.Count < state.TotalCharacters)
{
ushort charBytesRemaining = (ushort)(state.TotalCharacters - state.CharactersRead.Count);
if (!compressed)
charBytesRemaining *= 2;
if (bytesAvailable < charBytesRemaining)
bytesToRead = bytesAvailable;
else
bytesToRead = charBytesRemaining;
byte[] charBytes = data.Get(state.Offset, bytesToRead).ByteArray;
if (compressed)
{
//decompress
byte[] wideBytes = new byte[charBytes.Length * 2];
for (int i = 0; i < charBytes.Length; i++)
wideBytes[2 * i] = charBytes[i];
charBytes = wideBytes;
}
state.Offset += bytesToRead;
bytesAvailable -= bytesToRead;
state.CharactersRead.AddRange(Encoding.Unicode.GetChars(charBytes));
}
bool allCharsRead = state.CharactersRead.Count == state.TotalCharacters;
if (state.HasRichTextSettings && bytesAvailable > 0 && allCharsRead &&
state.FormattingRunBytes.Count < (state.FormattingRunCount * 4))
{
bytesToRead = Math.Min(bytesAvailable, (ushort) Math.Min(state.FormattingRunCount*4, ushort.MaxValue));
state.FormattingRunBytes.AddRange(data.Get(state.Offset, bytesToRead).ByteArray);
state.Offset += bytesToRead;
bytesAvailable -= bytesToRead;
}
if (state.HasAsianPhonetics && bytesAvailable > 0 && allCharsRead &&
state.PhoneticSettingsBytes.Count < state.PhoneticSettingsByteCount)
{
bytesToRead = Math.Min(bytesAvailable, (ushort)Math.Min(state.PhoneticSettingsByteCount, ushort.MaxValue));
state.PhoneticSettingsBytes.AddRange(data.Get(state.Offset, bytesToRead).ByteArray);
state.Offset += bytesToRead;
bytesAvailable -= bytesToRead;
}
if (state.CharactersRead.Count < state.TotalCharacters ||
state.FormattingRunBytes.Count < (state.FormattingRunCount * 4) ||
state.PhoneticSettingsBytes.Count < state.PhoneticSettingsByteCount)
{
state.Continue(true);
Read(state);
}
else if (bytesAvailable == 0 && (state.ContinueIndex + 1) < state.Record.Continues.Count)
{
state.Continue(false);
}
}