本文整理汇总了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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
}
示例8: EndXML
// ***************************************************************************
// Beendet an zu schreiben
public static void EndXML(XmlWriter writer)
{
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}