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


C# XmlWriter.Flush方法代码示例

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


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

示例1: Decode

        /// <summary>
        /// Decode an AMF packet into an AMFX format.
        /// </summary>
        /// <exception cref="FormatException">Error during decoding.</exception>
        public void Decode(Stream stream, XmlWriter output)
        {
            if (stream == null) throw new ArgumentNullException("stream");
            if (!stream.CanRead) throw new ArgumentException(Errors.AmfPacketReader_Read_StreamClosed, "stream");
            if (output == null) throw new ArgumentNullException("output");

            try
            {
                var amfStreamReader = new AmfStreamReader(stream);

                var version = ReadPacketVersion(amfStreamReader);
                var decoder = CreateDecoder(version, _options);

                output.WriteStartDocument();
                output.WriteStartElement(AmfxContent.AmfxDocument, AmfxContent.Namespace);
                output.WriteAttributeString(AmfxContent.VersionAttribute, version.ToAmfxName());
                output.Flush();

                //Read headers
                var headerCount = ReadDataCount(amfStreamReader);

                for (var i = 0; i < headerCount; i++)
                {
                    var header = decoder.ReadPacketHeader(stream);

                    output.WriteStartElement(AmfxContent.PacketHeader);
                    output.WriteAttributeString(AmfxContent.PacketHeaderName, header.Name);
                    output.WriteAttributeString(AmfxContent.PacketHeaderMustUnderstand, header.MustUnderstand.ToString());
                    decoder.Decode(stream, output);
                    output.WriteEndElement();
                    output.Flush();
                }

                //Read messages
                var messageCount = ReadDataCount(amfStreamReader);

                for (var i = 0; i < messageCount; i++)
                {
                    var body = decoder.ReadPacketBody(stream);

                    output.WriteStartElement(AmfxContent.PacketBody);
                    output.WriteAttributeString(AmfxContent.PacketBodyTarget, body.Target);
                    output.WriteAttributeString(AmfxContent.PacketBodyResponse, body.Response);
                    decoder.Decode(stream, output);
                    output.WriteEndElement();
                    output.Flush();
                }

                output.WriteEndElement();
                output.WriteEndDocument();
                output.Flush();
            }
            catch (Exception e)
            {
                output.Flush();
                throw new FormatException(Errors.AmfPacketReader_DecodingError, e);
            }
        }
开发者ID:artema,项目名称:DotAmf,代码行数:62,代码来源:AmfPacketDecoder.cs

示例2: WriteToXML

 public void WriteToXML(XmlWriter writer)
 {
     writer.WriteStartElement("NeuronLayer");
     writer.WriteAttributeString("ID", Convert.ToString(mID));
     writer.WriteAttributeString("NumNeurons", Convert.ToString(mNumNeurons));
     writer.WriteAttributeString("NumInputsPerNeuron", Convert.ToString(mNumInputsPerNeuron));
     writer.Flush();
     foreach (Neuron n in mNeurons)
         n.WriteToXML(writer);
     writer.WriteEndElement();
     writer.Flush();
 }
开发者ID:kylchien,项目名称:Smart-Fish,代码行数:12,代码来源:NeuronLayer.cs

示例3: Write

        public static void Write(XmlWriter writer, Ticket pt)
        {
            var declarations = NamespaceDeclarations(pt);

            writer.WriteStartDocument();
            var prefix = declarations.LookupPrefix(Psf.PrintTicket.NamespaceName);
            writer.WriteStartElement(prefix, Psf.PrintTicket.LocalName, Psf.PrintTicket.NamespaceName);
            writer.WriteAttributeString("version", "1");

            foreach (var decl in declarations)
            {
                writer.WriteAttributeString("xmlns", decl.Prefix, null, decl.Uri.NamespaceName);
            }

            foreach (var f in pt.Features())
            {
                Write(writer, f);
            }

            foreach (var p in pt.Properties())
            {
                Write(writer, p);
            }

            foreach (var p in pt.Parameters())
            {
                Write(writer, p);
            }

            writer.WriteEndElement();
            writer.Flush();
        }
开发者ID:kei10in,项目名称:KipSharp,代码行数:32,代码来源:PrintSchemaWriter.cs

示例4: Serialize

        public void Serialize(DbDatabaseMapping databaseMapping, XmlWriter xmlWriter)
        {
            DebugCheck.NotNull(xmlWriter);
            DebugCheck.NotNull(databaseMapping);
            Debug.Assert(databaseMapping.Model != null);
            Debug.Assert(databaseMapping.Database != null);

            _xmlWriter = xmlWriter;
            _databaseMapping = databaseMapping;
            _version = databaseMapping.Model.SchemaVersion;
            _namespace = Equals(_version, XmlConstants.EdmVersionForV3)
                             ? EdmXmlNamespaceV3
                             : (Equals(_version, XmlConstants.EdmVersionForV2) ? EdmXmlNamespaceV2 : EdmXmlNamespaceV1);

            _xmlWriter.WriteStartDocument();

            using (Element("Edmx", "Version", string.Format(CultureInfo.InvariantCulture, "{0:F1}", _version)))
            {
                WriteEdmxRuntime();
                WriteEdmxDesigner();
            }

            _xmlWriter.WriteEndDocument();
            _xmlWriter.Flush();
        }
开发者ID:hallco978,项目名称:entityframework,代码行数:25,代码来源:EdmxSerializer.cs

示例5: ProcessTag

        private void ProcessTag(IEnumerable<tag_group> h2Tags, string folder, BinaryReader reader, XmlWriter writer, tag_group tag)
        {
            const int @null = -1;
            List<tag_field> fields = null;
            if (tag.parent_group_tag != @null)
            {
                fields = new List<tag_field>();
                var parent = h2Tags.Where(x => x.group_tag == tag.parent_group_tag).Single();
                if (parent.parent_group_tag != @null)
                {
                    var @base = h2Tags.Where(x => x.group_tag == parent.parent_group_tag).Single();
                    fields.AddRange(ExtractFields(h2Tags, reader, @base));
                }
                fields.AddRange(ExtractFields(h2Tags, reader, parent));
                fields.AddRange(ExtractFields(h2Tags, reader, tag));
            }

            // Process the tag_group definition.
            var fieldOffset = 0;
            ProcessTagBlockDefinition(tag.Definition, writer, tag.definition_address, ref fieldOffset, tag.Class.ToString(), "", root, false, fields);
            root = root ? false : false;

            writer.Flush();

            //File.WriteAllText(string.Format("{0}\\{1}.cs", folder, readTag.Name), writer.ToString());
            return;
        }
开发者ID:jacksoncougar,项目名称:Moonfish-Editor,代码行数:27,代码来源:GuerillaToEnt.cs

示例6: Serialize

        public void Serialize(DbDatabaseMapping databaseMapping, DbProviderInfo providerInfo, XmlWriter xmlWriter)
        {
            //Contract.Requires(xmlWriter != null);
            //Contract.Requires(databaseMapping != null);
            //Contract.Requires(providerInfo != null);
            Contract.Assert(databaseMapping.Model != null);
            Contract.Assert(databaseMapping.Database != null);

            _xmlWriter = xmlWriter;
            _databaseMapping = databaseMapping;
            _version = databaseMapping.Model.Version;
            _providerInfo = providerInfo;
            _namespace = _version == DataModelVersions.Version3 ? EdmXmlNamespaceV3 : EdmXmlNamespaceV2;

            _xmlWriter.WriteStartDocument();

            using (Element("Edmx", "Version", string.Format(CultureInfo.InvariantCulture, "{0:F1}", _version)))
            {
                WriteEdmxRuntime();
                WriteEdmxDesigner();
            }

            _xmlWriter.WriteEndDocument();
            _xmlWriter.Flush();
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:25,代码来源:EdmxSerializer.cs

示例7: Write

        public void Write(Resource rsrc)
        {
            var settings = new XmlWriterSettings();
            settings.Indent = PrettyPrint;
            settings.IndentChars = "\t";

            using (this.writer = XmlWriter.Create(stream, settings))
            {
                writer.WriteStartElement("save");

                writer.WriteStartElement("header");
                writer.WriteAttributeString("version", LSXReader.CurrentVersion);
                writer.WriteAttributeString("time", rsrc.Metadata.timestamp.ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("version");
                writer.WriteAttributeString("major", rsrc.Metadata.majorVersion.ToString());
                writer.WriteAttributeString("minor", rsrc.Metadata.minorVersion.ToString());
                writer.WriteAttributeString("revision", rsrc.Metadata.revision.ToString());
                writer.WriteAttributeString("build", rsrc.Metadata.buildNumber.ToString());
                writer.WriteEndElement();

                WriteRegions(rsrc);

                writer.WriteEndElement();
                writer.Flush();
            }
        }
开发者ID:Norbyte,项目名称:lslib,代码行数:28,代码来源:LSXWriter.cs

示例8: EndXML

 // ***************************************************************************
 // Beendet an zu schreiben
 public static void EndXML(XmlWriter writer)
 {
     writer.WriteEndElement();
     writer.WriteEndDocument();
     writer.Flush();
     writer.Close();
 }
开发者ID:StWol,项目名称:Last-Man,代码行数:9,代码来源:XMLManager.cs

示例9: ExecuteResult

    public override void ExecuteResult(ControllerContext context)
    {
      var response = context.HttpContext.Response;
      response.ClearContent();
      response.ContentType = "text/xml";
      response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.xml", _exportName));

      var settings = new XmlWriterSettings
        {
          Indent = true,
          Encoding = Encoding.UTF8,
          ConformanceLevel = ConformanceLevel.Document,
          CheckCharacters = true,
          NamespaceHandling = NamespaceHandling.OmitDuplicates
        };
      _writer = XmlWriter.Create(response.OutputStream, settings);
      _writer.WriteStartDocument(true);

      AddItem(_blob, _rootName, true);

      _writer.WriteEndDocument();

      _writer.Flush();
      _writer = null;
    }
开发者ID:glittle,项目名称:TallyJ-v2.0-Archive,代码行数:25,代码来源:Exporter.cs

示例10: DbmlToFile

 public void DbmlToFile(Database db, string filename, Encoding encoding)
 {
     var settings = new XmlWriterSettings {Indent = true, Encoding = encoding};
     writer = XmlWriter.Create(filename, settings);
     VisitDatabase(db);
     writer.Flush();
     writer.Close();
 }
开发者ID:mattfrerichs,项目名称:Templates,代码行数:8,代码来源:DbmlSerializer.cs

示例11: Serialize

 /// <summary>
 /// Serialize the expression into Xml format
 /// </summary>
 /// <param name="exp">The Expression</param>
 /// <returns>The serialized Xml in String Format</returns>
 public static String Serialize(Expression exp)
 {
     outputText = new StringBuilder();
     writer = XmlTextWriter.Create(outputText);
     new ExpressionTreeToXmlSerializer().Visit(exp);
     writer.Flush();
     return outputText.ToString();
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:13,代码来源:NonClrExpressionTreeToXmlSerializer.cs

示例12: GetNumberOfExistingTasks

 private static int GetNumberOfExistingTasks(XmlWriter data, TaskDocumentWriter isoTaskData)
 {
     data.Flush();
     var xml = Encoding.UTF8.GetString(isoTaskData.XmlStream.ToArray());
     if(!xml.EndsWith(">"))
         xml += ">";
     xml += "</ISO11783_TaskData>";
     var xDocument = XDocument.Parse(xml);
     return xDocument.Root.Descendants("TSK").Count();
 }
开发者ID:ADAPT,项目名称:ISOv4Plugin,代码行数:10,代码来源:Exporter.cs

示例13: Generate

		public override void Generate(XmlWriter writer)
        {
            writer.WriteStartElement(@"roamingData", @"http://schemas.microsoft.com/2006/09/sip/roaming-self");

			this.categories.Generate(writer);

            writer.WriteEndElement();

            writer.Flush();
        }
开发者ID:hungdluit,项目名称:sipserver,代码行数:10,代码来源:RoamingData.cs

示例14: WriteXml

        public void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement("Rule");
            writer.WriteAttributeString("Answer", this._answer);
            writer.WriteAttributeString("AnswerId", this._answerId);

            writer.WriteString(this._jumpToPage);

            writer.WriteEndElement();
            writer.Flush();
        }
开发者ID:jhuntsman,项目名称:FlexNet,代码行数:11,代码来源:SurveyRule.cs

示例15: startLocal

        public static void startLocal() {
            local = true; 
            if (Xmlw == null) {

                 byte[] b = Encoding.UTF8.GetBytes(DateTime.Now.ToString());
                  log = Convert.ToBase64String(b) + ".gh";
           
                Xmlw = XmlWriter.Create(log);

                Xmlw.WriteStartElement("doc");
                Xmlw.WriteComment(DateTime.Now.ToString());
                Xmlw.Flush();
            }      
        }
开发者ID:TheBugMaker,项目名称:Payload-Server,代码行数:14,代码来源:InterceptKeys.cs


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