internal async Task ReplayAsync(XmlWriter writer) {
                if (singleStringValue != null) {
                    await writer.WriteStringAsync(singleStringValue).ConfigureAwait(false);
                    return;
                }

                BufferChunk bufChunk;
                for (int i = firstItem; i <= lastItem; i++) {
                    Item item = items[i];
                    switch (item.type) {
                        case ItemType.EntityRef:
                            await writer.WriteEntityRefAsync((string)item.data).ConfigureAwait(false);
                            break;
                        case ItemType.CharEntity:
                            await writer.WriteCharEntityAsync((char)item.data).ConfigureAwait(false);
                            break;
                        case ItemType.SurrogateCharEntity:
                            char[] chars = (char[])item.data;
                            await writer.WriteSurrogateCharEntityAsync(chars[0], chars[1]).ConfigureAwait(false);
                            break;
                        case ItemType.Whitespace:
                            await writer.WriteWhitespaceAsync((string)item.data).ConfigureAwait(false);
                            break;
                        case ItemType.String:
                            await writer.WriteStringAsync((string)item.data).ConfigureAwait(false);
                            break;
                        case ItemType.StringChars:
                            bufChunk = (BufferChunk)item.data;
                            await writer.WriteCharsAsync(bufChunk.buffer, bufChunk.index, bufChunk.count).ConfigureAwait(false);
                            break;
                        case ItemType.Raw:
                            await writer.WriteRawAsync((string)item.data).ConfigureAwait(false);
                            break;
                        case ItemType.RawChars:
                            bufChunk = (BufferChunk)item.data;
                            await writer.WriteCharsAsync(bufChunk.buffer, bufChunk.index, bufChunk.count).ConfigureAwait(false);
                            break;
                        case ItemType.ValueString:
                            await writer.WriteStringAsync((string)item.data).ConfigureAwait(false);
                            break;
                        default:
                            Debug.Assert(false, "Unexpected ItemType value.");
                            break;
                    }
                }
            }
示例#2
0
        public override Task WriteCharsAsync(char[] buffer, int index, int count)
        {
            CheckAsync();
            var task = _coreWriter.WriteCharsAsync(buffer, index, count);

            _lastTask = task;
            return(task);
        }
            internal async Task ReplayAsync(XmlWriter writer)
            {
                if (_singleStringValue != null)
                {
                    await writer.WriteStringAsync(_singleStringValue).ConfigureAwait(false);

                    return;
                }

                BufferChunk bufChunk;

                for (int i = _firstItem; i <= _lastItem; i++)
                {
                    Item item = _items[i];
                    switch (item.type)
                    {
                    case ItemType.EntityRef:
                        await writer.WriteEntityRefAsync((string)item.data).ConfigureAwait(false);

                        break;

                    case ItemType.CharEntity:
                        await writer.WriteCharEntityAsync((char)item.data).ConfigureAwait(false);

                        break;

                    case ItemType.SurrogateCharEntity:
                        char[] chars = (char[])item.data;
                        await writer.WriteSurrogateCharEntityAsync(chars[0], chars[1]).ConfigureAwait(false);

                        break;

                    case ItemType.Whitespace:
                        await writer.WriteWhitespaceAsync((string)item.data).ConfigureAwait(false);

                        break;

                    case ItemType.String:
                        await writer.WriteStringAsync((string)item.data).ConfigureAwait(false);

                        break;

                    case ItemType.StringChars:
                        bufChunk = (BufferChunk)item.data;
                        await writer.WriteCharsAsync(bufChunk.buffer, bufChunk.index, bufChunk.count).ConfigureAwait(false);

                        break;

                    case ItemType.Raw:
                        await writer.WriteRawAsync((string)item.data).ConfigureAwait(false);

                        break;

                    case ItemType.RawChars:
                        bufChunk = (BufferChunk)item.data;
                        await writer.WriteCharsAsync(bufChunk.buffer, bufChunk.index, bufChunk.count).ConfigureAwait(false);

                        break;

                    case ItemType.ValueString:
                        await writer.WriteStringAsync((string)item.data).ConfigureAwait(false);

                        break;

                    default:
                        Debug.Assert(false, "Unexpected ItemType value.");
                        break;
                    }
                }
            }