WriteCharEntity() public abstract method

public abstract WriteCharEntity ( char ch ) : void
ch char
return void
Beispiel #1
0
        /// <summary>
        /// Replay all cached events to an XmlWriter.
        /// </summary>
        public void EventsToWriter(XmlWriter writer) {
            XmlEvent[] page;
            int idxPage, idxEvent;
            byte[] bytes;
            char[] chars;
            XmlRawWriter rawWriter;

            // Special-case single text node at the top-level
            if (this.singleText.Count != 0) {
                writer.WriteString(this.singleText.GetResult());
                return;
            }

            rawWriter = writer as XmlRawWriter;

            // Loop over set of pages
            for (idxPage = 0; idxPage < this.pages.Count; idxPage++) {
                page = this.pages[idxPage];

                // Loop over events in each page
                for (idxEvent = 0; idxEvent < page.Length; idxEvent++) {
                    switch (page[idxEvent].EventType) {
                        case XmlEventType.Unknown:
                            // No more events
                            Debug.Assert(idxPage + 1 == this.pages.Count);
                            return;

                        case XmlEventType.DocType:
                            writer.WriteDocType(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3, (string) page[idxEvent].Object);
                            break;

                        case XmlEventType.StartElem:
                            writer.WriteStartElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                            break;

                        case XmlEventType.StartAttr:
                            writer.WriteStartAttribute(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                            break;

                        case XmlEventType.EndAttr:
                            writer.WriteEndAttribute();
                            break;

                        case XmlEventType.CData:
                            writer.WriteCData(page[idxEvent].String1);
                            break;

                        case XmlEventType.Comment:
                            writer.WriteComment(page[idxEvent].String1);
                            break;

                        case XmlEventType.PI:
                            writer.WriteProcessingInstruction(page[idxEvent].String1, page[idxEvent].String2);
                            break;

                        case XmlEventType.Whitespace:
                            writer.WriteWhitespace(page[idxEvent].String1);
                            break;

                        case XmlEventType.String:
                            writer.WriteString(page[idxEvent].String1);
                            break;

                        case XmlEventType.Raw:
                            writer.WriteRaw(page[idxEvent].String1);
                            break;

                        case XmlEventType.EntRef:
                            writer.WriteEntityRef(page[idxEvent].String1);
                            break;

                        case XmlEventType.CharEnt:
                            writer.WriteCharEntity((char) page[idxEvent].Object);
                            break;

                        case XmlEventType.SurrCharEnt:
                            chars = (char[]) page[idxEvent].Object;
                            writer.WriteSurrogateCharEntity(chars[0], chars[1]);
                            break;

                        case XmlEventType.Base64:
                            bytes = (byte[]) page[idxEvent].Object;
                            writer.WriteBase64(bytes, 0, bytes.Length);
                            break;

                        case XmlEventType.BinHex:
                            bytes = (byte[]) page[idxEvent].Object;
                            writer.WriteBinHex(bytes, 0, bytes.Length);
                            break;

                        case XmlEventType.XmlDecl1:
                            if (rawWriter != null)
                                rawWriter.WriteXmlDeclaration((XmlStandalone) page[idxEvent].Object);
                            break;

                        case XmlEventType.XmlDecl2:
                            if (rawWriter != null)
                                rawWriter.WriteXmlDeclaration(page[idxEvent].String1);
                            break;

                        case XmlEventType.StartContent:
                            if (rawWriter != null)
                                rawWriter.StartElementContent();
                            break;

                        case XmlEventType.EndElem:
                            if (rawWriter != null)
                                rawWriter.WriteEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                            else
                                writer.WriteEndElement();
                            break;

                        case XmlEventType.FullEndElem:
                            if (rawWriter != null)
                                rawWriter.WriteFullEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                            else
                                writer.WriteFullEndElement();
                            break;

                        case XmlEventType.Nmsp:
                            if (rawWriter != null)
                                rawWriter.WriteNamespaceDeclaration(page[idxEvent].String1, page[idxEvent].String2);
                            else
                                writer.WriteAttributeString("xmlns", page[idxEvent].String1, XmlReservedNs.NsXmlNs, page[idxEvent].String2);
                            break;

                        case XmlEventType.EndBase64:
                            if (rawWriter != null)
                                rawWriter.WriteEndBase64();
                            break;

                        case XmlEventType.Close:
                            writer.Close();
                            break;

                        case XmlEventType.Flush:
                            writer.Flush();
                            break;

                        case XmlEventType.Dispose:
                            ((IDisposable)writer).Dispose();
                            break;

                        default:
                            Debug.Assert(false, "Unknown event: " + page[idxEvent].EventType);
                            break;
                    }
                }
            }

            Debug.Assert(false, "Unknown event should be added to end of event sequence.");
        }
            internal void Replay(XmlWriter writer)
            {
                if (_singleStringValue != null)
                {
                    writer.WriteString(_singleStringValue);
                    return;
                }

                BufferChunk bufChunk;
                for (int i = _firstItem; i <= _lastItem; i++)
                {
                    Item item = _items[i];
                    switch (item.type)
                    {
                        case ItemType.EntityRef:
                            writer.WriteEntityRef((string)item.data);
                            break;
                        case ItemType.CharEntity:
                            writer.WriteCharEntity((char)item.data);
                            break;
                        case ItemType.SurrogateCharEntity:
                            char[] chars = (char[])item.data;
                            writer.WriteSurrogateCharEntity(chars[0], chars[1]);
                            break;
                        case ItemType.Whitespace:
                            writer.WriteWhitespace((string)item.data);
                            break;
                        case ItemType.String:
                            writer.WriteString((string)item.data);
                            break;
                        case ItemType.StringChars:
                            bufChunk = (BufferChunk)item.data;
                            writer.WriteChars(bufChunk.buffer, bufChunk.index, bufChunk.count);
                            break;
                        case ItemType.Raw:
                            writer.WriteRaw((string)item.data);
                            break;
                        case ItemType.RawChars:
                            bufChunk = (BufferChunk)item.data;
                            writer.WriteChars(bufChunk.buffer, bufChunk.index, bufChunk.count);
                            break;
                        case ItemType.ValueString:
                            writer.WriteValue((string)item.data);
                            break;
                        default:
                            Debug.Fail("Unexpected ItemType value.");
                            break;
                    }
                }
            }
 public override void WriteCharEntity(char ch)
 {
     EndCDataSection();
     _wrapped.WriteCharEntity(ch);
 }
Beispiel #4
0
 private void InvokeMethod(XmlWriter w, string methodName)
 {
     byte[] buffer = new byte[10];
     switch (methodName)
     {
         case "WriteStartDocument":
             w.WriteStartDocument();
             break;
         case "WriteStartElement":
             w.WriteStartElement("root");
             break;
         case "WriteEndElement":
             w.WriteEndElement();
             break;
         case "WriteStartAttribute":
             w.WriteStartAttribute("attr");
             break;
         case "WriteEndAttribute":
             w.WriteEndAttribute();
             break;
         case "WriteCData":
             w.WriteCData("test");
             break;
         case "WriteComment":
             w.WriteComment("test");
             break;
         case "WritePI":
             w.WriteProcessingInstruction("name", "test");
             break;
         case "WriteEntityRef":
             w.WriteEntityRef("e");
             break;
         case "WriteCharEntity":
             w.WriteCharEntity('c');
             break;
         case "WriteSurrogateCharEntity":
             w.WriteSurrogateCharEntity('\uDC00', '\uDBFF');
             break;
         case "WriteWhitespace":
             w.WriteWhitespace(" ");
             break;
         case "WriteString":
             w.WriteString("foo");
             break;
         case "WriteChars":
             char[] charArray = new char[] { 'a', 'b', 'c', 'd' };
             w.WriteChars(charArray, 0, 3);
             break;
         case "WriteRaw":
             w.WriteRaw("<foo>bar</foo>");
             break;
         case "WriteBase64":
             w.WriteBase64(buffer, 0, 9);
             break;
         case "WriteBinHex":
             w.WriteBinHex(buffer, 0, 9);
             break;
         case "LookupPrefix":
             string str = w.LookupPrefix("foo");
             break;
         case "WriteNmToken":
             w.WriteNmToken("foo");
             break;
         case "WriteName":
             w.WriteName("foo");
             break;
         case "WriteQualifiedName":
             w.WriteQualifiedName("foo", "bar");
             break;
         case "WriteValue":
             w.WriteValue(Int32.MaxValue);
             break;
         case "WriteAttributes":
             XmlReader xr1 = ReaderHelper.Create(new StringReader("<root attr='test'/>"));
             xr1.Read();
             w.WriteAttributes(xr1, false);
             break;
         case "WriteNodeReader":
             XmlReader xr2 = ReaderHelper.Create(new StringReader("<root/>"));
             xr2.Read();
             w.WriteNode(xr2, false);
             break;
         case "Flush":
             w.Flush();
             break;
         default:
             CError.Equals(false, "Unexpected param in testcase: {0}", methodName);
             break;
     }
 }
Beispiel #5
0
 public override void WriteCharEntity(char ch)
 {
     _writer.WriteCharEntity(ch);
 }
 public override void WriteCharEntity(char ch)
 {
     CheckAsync();
     _coreWriter.WriteCharEntity(ch);
 }
Beispiel #7
0
        /// <summary>
        /// Replay all cached events to an XmlWriter.
        /// </summary>
        public void EventsToWriter(XmlWriter writer)
        {
            XmlEvent[] page;
            int        idxPage, idxEvent;

            byte[]       bytes;
            char[]       chars;
            XmlRawWriter rawWriter;

            // Special-case single text node at the top-level
            if (_singleText.Count != 0)
            {
                writer.WriteString(_singleText.GetResult());
                return;
            }

            rawWriter = writer as XmlRawWriter;

            // Loop over set of pages
            for (idxPage = 0; idxPage < _pages.Count; idxPage++)
            {
                page = _pages[idxPage];

                // Loop over events in each page
                for (idxEvent = 0; idxEvent < page.Length; idxEvent++)
                {
                    switch (page[idxEvent].EventType)
                    {
                    case XmlEventType.Unknown:
                        // No more events
                        Debug.Assert(idxPage + 1 == _pages.Count);
                        return;

                    case XmlEventType.DocType:
                        writer.WriteDocType(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3, (string)page[idxEvent].Object);
                        break;

                    case XmlEventType.StartElem:
                        writer.WriteStartElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                        break;

                    case XmlEventType.StartAttr:
                        writer.WriteStartAttribute(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                        break;

                    case XmlEventType.EndAttr:
                        writer.WriteEndAttribute();
                        break;

                    case XmlEventType.CData:
                        writer.WriteCData(page[idxEvent].String1);
                        break;

                    case XmlEventType.Comment:
                        writer.WriteComment(page[idxEvent].String1);
                        break;

                    case XmlEventType.PI:
                        writer.WriteProcessingInstruction(page[idxEvent].String1, page[idxEvent].String2);
                        break;

                    case XmlEventType.Whitespace:
                        writer.WriteWhitespace(page[idxEvent].String1);
                        break;

                    case XmlEventType.String:
                        writer.WriteString(page[idxEvent].String1);
                        break;

                    case XmlEventType.Raw:
                        writer.WriteRaw(page[idxEvent].String1);
                        break;

                    case XmlEventType.EntRef:
                        writer.WriteEntityRef(page[idxEvent].String1);
                        break;

                    case XmlEventType.CharEnt:
                        writer.WriteCharEntity((char)page[idxEvent].Object);
                        break;

                    case XmlEventType.SurrCharEnt:
                        chars = (char[])page[idxEvent].Object;
                        writer.WriteSurrogateCharEntity(chars[0], chars[1]);
                        break;

                    case XmlEventType.Base64:
                        bytes = (byte[])page[idxEvent].Object;
                        writer.WriteBase64(bytes, 0, bytes.Length);
                        break;

                    case XmlEventType.BinHex:
                        bytes = (byte[])page[idxEvent].Object;
                        writer.WriteBinHex(bytes, 0, bytes.Length);
                        break;

                    case XmlEventType.XmlDecl1:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteXmlDeclaration((XmlStandalone)page[idxEvent].Object);
                        }
                        break;

                    case XmlEventType.XmlDecl2:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteXmlDeclaration(page[idxEvent].String1);
                        }
                        break;

                    case XmlEventType.StartContent:
                        if (rawWriter != null)
                        {
                            rawWriter.StartElementContent();
                        }
                        break;

                    case XmlEventType.EndElem:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                        }
                        else
                        {
                            writer.WriteEndElement();
                        }
                        break;

                    case XmlEventType.FullEndElem:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteFullEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                        }
                        else
                        {
                            writer.WriteFullEndElement();
                        }
                        break;

                    case XmlEventType.Nmsp:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteNamespaceDeclaration(page[idxEvent].String1, page[idxEvent].String2);
                        }
                        else
                        {
                            writer.WriteAttributeString("xmlns", page[idxEvent].String1, XmlReservedNs.NsXmlNs, page[idxEvent].String2);
                        }
                        break;

                    case XmlEventType.EndBase64:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteEndBase64();
                        }
                        break;

                    case XmlEventType.Close:
                        writer.Close();
                        break;

                    case XmlEventType.Flush:
                        writer.Flush();
                        break;

                    case XmlEventType.Dispose:
                        ((IDisposable)writer).Dispose();
                        break;

                    default:
                        Debug.Assert(false, "Unknown event: " + page[idxEvent].EventType);
                        break;
                    }
                }
            }

            Debug.Assert(false, "Unknown event should be added to end of event sequence.");
        }
 public override void WriteCharEntity(char ch)
 {
     writer.WriteCharEntity(ch);
     state = WriteState.Content;
 }
 public override void WriteCharEntity(char c)
 {
     CheckState();
     w.WriteCharEntity(c);
 }
Beispiel #10
0
        public void EventsToWriter(XmlWriter writer)
        {
            if (this.singleText.Count != 0)
            {
                writer.WriteString(this.singleText.GetResult());
            }
            else
            {
                XmlRawWriter writer2 = writer as XmlRawWriter;
                for (int i = 0; i < this.pages.Count; i++)
                {
                    XmlEvent[] eventArray = this.pages[i];
                    for (int j = 0; j < eventArray.Length; j++)
                    {
                        byte[] buffer;
                        switch (eventArray[j].EventType)
                        {
                        case XmlEventType.Unknown:
                            return;

                        case XmlEventType.DocType:
                        {
                            writer.WriteDocType(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3, (string)eventArray[j].Object);
                            continue;
                        }

                        case XmlEventType.StartElem:
                        {
                            writer.WriteStartElement(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3);
                            continue;
                        }

                        case XmlEventType.StartAttr:
                        {
                            writer.WriteStartAttribute(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3);
                            continue;
                        }

                        case XmlEventType.EndAttr:
                        {
                            writer.WriteEndAttribute();
                            continue;
                        }

                        case XmlEventType.CData:
                        {
                            writer.WriteCData(eventArray[j].String1);
                            continue;
                        }

                        case XmlEventType.Comment:
                        {
                            writer.WriteComment(eventArray[j].String1);
                            continue;
                        }

                        case XmlEventType.PI:
                        {
                            writer.WriteProcessingInstruction(eventArray[j].String1, eventArray[j].String2);
                            continue;
                        }

                        case XmlEventType.Whitespace:
                        {
                            writer.WriteWhitespace(eventArray[j].String1);
                            continue;
                        }

                        case XmlEventType.String:
                        {
                            writer.WriteString(eventArray[j].String1);
                            continue;
                        }

                        case XmlEventType.Raw:
                        {
                            writer.WriteRaw(eventArray[j].String1);
                            continue;
                        }

                        case XmlEventType.EntRef:
                        {
                            writer.WriteEntityRef(eventArray[j].String1);
                            continue;
                        }

                        case XmlEventType.CharEnt:
                        {
                            writer.WriteCharEntity((char)eventArray[j].Object);
                            continue;
                        }

                        case XmlEventType.SurrCharEnt:
                        {
                            char[] chArray = (char[])eventArray[j].Object;
                            writer.WriteSurrogateCharEntity(chArray[0], chArray[1]);
                            continue;
                        }

                        case XmlEventType.Base64:
                        {
                            buffer = (byte[])eventArray[j].Object;
                            writer.WriteBase64(buffer, 0, buffer.Length);
                            continue;
                        }

                        case XmlEventType.BinHex:
                        {
                            buffer = (byte[])eventArray[j].Object;
                            writer.WriteBinHex(buffer, 0, buffer.Length);
                            continue;
                        }

                        case XmlEventType.XmlDecl1:
                        {
                            if (writer2 != null)
                            {
                                writer2.WriteXmlDeclaration((XmlStandalone)eventArray[j].Object);
                            }
                            continue;
                        }

                        case XmlEventType.XmlDecl2:
                        {
                            if (writer2 != null)
                            {
                                writer2.WriteXmlDeclaration(eventArray[j].String1);
                            }
                            continue;
                        }

                        case XmlEventType.StartContent:
                        {
                            if (writer2 != null)
                            {
                                writer2.StartElementContent();
                            }
                            continue;
                        }

                        case XmlEventType.EndElem:
                        {
                            if (writer2 == null)
                            {
                                break;
                            }
                            writer2.WriteEndElement(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3);
                            continue;
                        }

                        case XmlEventType.FullEndElem:
                        {
                            if (writer2 == null)
                            {
                                goto Label_0367;
                            }
                            writer2.WriteFullEndElement(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3);
                            continue;
                        }

                        case XmlEventType.Nmsp:
                        {
                            if (writer2 == null)
                            {
                                goto Label_0394;
                            }
                            writer2.WriteNamespaceDeclaration(eventArray[j].String1, eventArray[j].String2);
                            continue;
                        }

                        case XmlEventType.EndBase64:
                        {
                            if (writer2 != null)
                            {
                                writer2.WriteEndBase64();
                            }
                            continue;
                        }

                        case XmlEventType.Close:
                        {
                            writer.Close();
                            continue;
                        }

                        case XmlEventType.Flush:
                        {
                            writer.Flush();
                            continue;
                        }

                        case XmlEventType.Dispose:
                        {
                            writer.Dispose();
                            continue;
                        }

                        default:
                        {
                            continue;
                        }
                        }
                        writer.WriteEndElement();
                        continue;
Label_0367:
                        writer.WriteFullEndElement();
                        continue;
Label_0394:
                        writer.WriteAttributeString("xmlns", eventArray[j].String1, "http://www.w3.org/2000/xmlns/", eventArray[j].String2);
                    }
                }
            }
        }
            internal void Replay(XmlWriter writer)
            {
                if (this.singleStringValue != null)
                {
                    writer.WriteString(this.singleStringValue);
                }
                else
                {
                    for (int i = this.firstItem; i <= this.lastItem; i++)
                    {
                        BufferChunk chunk;
                        Item item = this.items[i];
                        switch (item.type)
                        {
                            case ItemType.EntityRef:
                                writer.WriteEntityRef((string) item.data);
                                break;

                            case ItemType.CharEntity:
                                writer.WriteCharEntity((char) item.data);
                                break;

                            case ItemType.SurrogateCharEntity:
                            {
                                char[] data = (char[]) item.data;
                                writer.WriteSurrogateCharEntity(data[0], data[1]);
                                break;
                            }
                            case ItemType.Whitespace:
                                writer.WriteWhitespace((string) item.data);
                                break;

                            case ItemType.String:
                                writer.WriteString((string) item.data);
                                break;

                            case ItemType.StringChars:
                                chunk = (BufferChunk) item.data;
                                writer.WriteChars(chunk.buffer, chunk.index, chunk.count);
                                break;

                            case ItemType.Raw:
                                writer.WriteRaw((string) item.data);
                                break;

                            case ItemType.RawChars:
                                chunk = (BufferChunk) item.data;
                                writer.WriteChars(chunk.buffer, chunk.index, chunk.count);
                                break;

                            case ItemType.ValueString:
                                writer.WriteValue((string) item.data);
                                break;
                        }
                    }
                }
            }