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


C# XmlWriter.WriteSurrogateCharEntity方法代码示例

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


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

示例1: Replay

            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;
                    }
                }
            }
开发者ID:johnhhm,项目名称:corefx,代码行数:50,代码来源:XmlWellformedWriterHelpers.cs

示例2: InvokeMethod

 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;
     }
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:90,代码来源:CommonTests.cs

示例3: EventsToWriter

        /// <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)
//.........这里部分代码省略.........
开发者ID:uQr,项目名称:referencesource,代码行数:101,代码来源:XmlEventCache.cs

示例4: Replay

            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;
                        }
                    }
                }
            }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:57,代码来源:XmlWellFormedWriter.cs


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