Example #1
0
        public override Task WriteCharEntityAsync(char ch)
        {
            CheckAsync();
            var task = _coreWriter.WriteCharEntityAsync(ch);

            _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;
                    }
                }
            }
            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;
                    }
                }
            }