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


C# XmlUtilWriter.Flush方法代码示例

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


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

示例1: StreamWriterCheckpoint

            internal StreamWriterCheckpoint(XmlUtilWriter writer)
            {
                writer.Flush();
                _lineNumber = writer.LineNumber;
                _linePosition = writer.LinePosition;
                _isLastLineBlank = writer.IsLastLineBlank;

                writer._baseStream.Flush();
                _streamPosition = writer._baseStream.Position;
                _streamLength = writer._baseStream.Length;
            }
开发者ID:chcosta,项目名称:corefx,代码行数:11,代码来源:XmlUtilWriter.cs

示例2: CopySection

        //
        // Copy a configuration section to a string, and advance the reader.
        //
        internal string CopySection() {
            ResetCachedStringWriter();

            // Preserve whitespace for sections for backcompat
            WhitespaceHandling originalHandling = _reader.WhitespaceHandling;
            _reader.WhitespaceHandling = WhitespaceHandling.All;

            // Create string writer to write to
            XmlUtilWriter utilWriter = new XmlUtilWriter(_cachedStringWriter, false);

            // Copy the element
            CopyElement(utilWriter);

            // Reset whitespace handling
            _reader.WhitespaceHandling = originalHandling;

            if ((originalHandling == WhitespaceHandling.None) &&
                 (Reader.NodeType  == XmlNodeType.Whitespace))  {
                // If we were previously suppose to skip whitespace, and now we
                // are at it, then lets jump to the next item
                _reader.Read();
            }

            utilWriter.Flush();
            string s = ((StringWriter)utilWriter.Writer).ToString();
            return s;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:30,代码来源:xmlutil.cs

示例3: FormatXmlElement

        // Format an Xml element to be written to the config file.
        // Params:
        //   xmlElement      - the element
        //   linePosition    - start position of the element
        //   indent          - indent for each depth
        //   skipFirstIndent - skip indent for the first element?
        //
        static internal string FormatXmlElement(string xmlElement, int linePosition, int indent, bool skipFirstIndent) {

            XmlParserContext context = new XmlParserContext(null, null, null, XmlSpace.Default, Encoding.Unicode);
            XmlTextReader reader = new XmlTextReader(xmlElement, XmlNodeType.Element, context);

            StringWriter stringWriter = new StringWriter(new StringBuilder(64), CultureInfo.InvariantCulture);
            XmlUtilWriter utilWriter = new XmlUtilWriter(stringWriter, false);

            // append newline before indent?
            bool newLine = false;

            // last node visited was text?
            bool lastWasText = false;

            // width of line from end of indentation
            int lineWidth;

            // length of the stringbuilder after last indent with newline
            int sbLengthLastNewLine = 0;

            while (reader.Read()) {
                XmlNodeType nodeType = reader.NodeType;

                if (lastWasText) {
                    utilWriter.Flush();
                    lineWidth = sbLengthLastNewLine - ((StringWriter)utilWriter.Writer).GetStringBuilder().Length;
                }
                else {
                    lineWidth = 0;
                }

                switch (nodeType) {
                    case XmlNodeType.CDATA:
                    case XmlNodeType.Element:
                    case XmlNodeType.EndElement:
                    case XmlNodeType.Comment:
                        // Do not indent if the last node was text - doing so would add whitespace
                        // that is included as part of the text.
                        if (!skipFirstIndent && !lastWasText) {
                            utilWriter.AppendIndent(linePosition, indent, reader.Depth, newLine);

                            if (newLine) {
                                utilWriter.Flush();
                                sbLengthLastNewLine = ((StringWriter)utilWriter.Writer).GetStringBuilder().Length;
                            }
                        }
                        break;

                    default:
                        break;
                }

                lastWasText = false;
                switch (nodeType) {
                    case XmlNodeType.Whitespace:
                        break;

                    case XmlNodeType.SignificantWhitespace:
                        utilWriter.Write(reader.Value);
                        break;

                    case XmlNodeType.CDATA:
                        utilWriter.AppendCData(reader.Value);
                        break;

                    case XmlNodeType.ProcessingInstruction:
                        utilWriter.AppendProcessingInstruction(reader.Name, reader.Value);
                        break;

                    case XmlNodeType.Comment:
                        utilWriter.AppendComment(reader.Value);
                        break;

                    case XmlNodeType.Text:
                        utilWriter.AppendEscapeTextString(reader.Value);
                        lastWasText = true;
                        break;

                    case XmlNodeType.Element:
                        {
                            // Write "<elem"
                            utilWriter.Write('<');
                            utilWriter.Write(reader.Name);

                            lineWidth += reader.Name.Length + 2;

                            int c = reader.AttributeCount;
                            for (int i = 0; i < c; i++) {
                                // Add new line if we've exceeded the line width
                                bool writeSpace;
                                if (lineWidth > MAX_LINE_WIDTH) {
                                    utilWriter.AppendIndent(linePosition, indent, reader.Depth - 1, true);
                                    lineWidth = indent;
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:xmlutil.cs

示例4: FormatXmlElement

        internal static string FormatXmlElement(string xmlElement, int linePosition, int indent, bool skipFirstIndent)
        {
            XmlParserContext context = new XmlParserContext(null, null, null, XmlSpace.Default, Encoding.Unicode);
            XmlTextReader reader = new XmlTextReader(xmlElement, XmlNodeType.Element, context);
            StringWriter writer = new StringWriter(new StringBuilder(0x40), CultureInfo.InvariantCulture);
            XmlUtilWriter writer2 = new XmlUtilWriter(writer, false);
            bool newLine = false;
            bool flag2 = false;
            int num2 = 0;
            while (reader.Read())
            {
                int num;
                int attributeCount;
                int num4;
                bool flag3;
                XmlNodeType nodeType = reader.NodeType;
                if (flag2)
                {
                    writer2.Flush();
                    num = num2 - ((StringWriter) writer2.Writer).GetStringBuilder().Length;
                }
                else
                {
                    num = 0;
                }
                XmlNodeType type2 = nodeType;
                if (type2 <= XmlNodeType.CDATA)
                {
                    switch (type2)
                    {
                        case XmlNodeType.Element:
                        case XmlNodeType.CDATA:
                            goto Label_0091;
                    }
                    goto Label_00CA;
                }
                if ((type2 != XmlNodeType.Comment) && (type2 != XmlNodeType.EndElement))
                {
                    goto Label_00CA;
                }
            Label_0091:
                if (!skipFirstIndent && !flag2)
                {
                    writer2.AppendIndent(linePosition, indent, reader.Depth, newLine);
                    if (newLine)
                    {
                        writer2.Flush();
                        num2 = ((StringWriter) writer2.Writer).GetStringBuilder().Length;
                    }
                }
            Label_00CA:
                flag2 = false;
                switch (nodeType)
                {
                    case XmlNodeType.Element:
                        writer2.Write('<');
                        writer2.Write(reader.Name);
                        num += reader.Name.Length + 2;
                        attributeCount = reader.AttributeCount;
                        num4 = 0;
                        goto Label_0274;

                    case XmlNodeType.Text:
                        writer2.AppendEscapeTextString(reader.Value);
                        flag2 = true;
                        goto Label_02D6;

                    case XmlNodeType.CDATA:
                        writer2.AppendCData(reader.Value);
                        goto Label_02D6;

                    case XmlNodeType.EntityReference:
                        writer2.AppendEntityRef(reader.Name);
                        goto Label_02D6;

                    case XmlNodeType.ProcessingInstruction:
                        writer2.AppendProcessingInstruction(reader.Name, reader.Value);
                        goto Label_02D6;

                    case XmlNodeType.Comment:
                        writer2.AppendComment(reader.Value);
                        goto Label_02D6;

                    case XmlNodeType.SignificantWhitespace:
                        writer2.Write(reader.Value);
                        goto Label_02D6;

                    case XmlNodeType.EndElement:
                        writer2.Write("</");
                        writer2.Write(reader.Name);
                        writer2.Write('>');
                        goto Label_02D6;

                    default:
                        goto Label_02D6;
                }
            Label_01BE:
                if (num > 60)
                {
                    writer2.AppendIndent(linePosition, indent, reader.Depth - 1, true);
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:XmlUtil.cs

示例5: CopySection

 internal string CopySection()
 {
     this.ResetCachedStringWriter();
     WhitespaceHandling whitespaceHandling = this._reader.WhitespaceHandling;
     this._reader.WhitespaceHandling = WhitespaceHandling.All;
     XmlUtilWriter utilWriter = new XmlUtilWriter(this._cachedStringWriter, false);
     this.CopyElement(utilWriter);
     this._reader.WhitespaceHandling = whitespaceHandling;
     if ((whitespaceHandling == WhitespaceHandling.None) && (this.Reader.NodeType == XmlNodeType.Whitespace))
     {
         this._reader.Read();
     }
     utilWriter.Flush();
     return ((StringWriter) utilWriter.Writer).ToString();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:XmlUtil.cs

示例6: CopySection

        //
        // Copy a configuration section to a string, and advance the reader.
        //
        internal string CopySection()
        {
            ResetCachedStringWriter();

            // Preserve whitespace for sections for backcompat
            //WhitespaceHandling originalHandling = _reader.WhitespaceHandling;
            //_reader.WhitespaceHandling = WhitespaceHandling.All;

            // Create string writer to write to
            XmlUtilWriter utilWriter = new XmlUtilWriter(_cachedStringWriter, false);

            // Copy the element
            CopyElement(utilWriter);

            // Reset whitespace handling

            utilWriter.Flush();
            string s = ((StringWriter)utilWriter.Writer).ToString();
            return s;
        }
开发者ID:kichalla,项目名称:systemconfigurationport,代码行数:23,代码来源:XmlUtil.cs


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