本文整理汇总了C#中System.Xml.XmlWriter.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriter.Dispose方法的具体用法?C# XmlWriter.Dispose怎么用?C# XmlWriter.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlWriter
的用法示例。
在下文中一共展示了XmlWriter.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReturnStreamedWriter
private void ReturnStreamedWriter(XmlWriter xmlWriter)
{
Contract.Assert(xmlWriter != null, "xmlWriter MUST NOT be null");
xmlWriter.Flush();
xmlWriter.Dispose();
}
示例2: Serialize
public void Serialize(World world, Stream stream)
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.NewLineOnAttributes = false;
settings.OmitXmlDeclaration = true;
_writer = XmlWriter.Create(stream, settings);
_writer.WriteStartElement("World");
_writer.WriteAttributeString("Version", "2");
WriteElement("Gravity", world.Gravity);
_writer.WriteStartElement("Shapes");
for (int i = 0; i < world.BodyList.Count; i++)
{
Body body = world.BodyList[i];
for (int j = 0; j < body.FixtureList.Count; j++)
{
Fixture fixture = body.FixtureList[j];
bool alreadyThere = false;
for (int k = 0; k < _serializedShapes.Count; k++)
{
Shape s2 = _serializedShapes[k];
if (fixture.Shape.CompareTo(s2))
{
alreadyThere = true;
break;
}
}
if (!alreadyThere)
{
SerializeShape(fixture.Shape);
_serializedShapes.Add(fixture.Shape);
}
}
}
_writer.WriteEndElement();
_writer.WriteStartElement("Fixtures");
for (int i = 0; i < world.BodyList.Count; i++)
{
Body body = world.BodyList[i];
for (int j = 0; j < body.FixtureList.Count; j++)
{
Fixture fixture = body.FixtureList[j];
bool alreadyThere = false;
for (int k = 0; k < _serializedFixtures.Count; k++)
{
Fixture f2 = _serializedFixtures[k];
if (fixture.CompareTo(f2))
{
alreadyThere = true;
break;
}
}
if (!alreadyThere)
{
SerializeFixture(fixture);
_serializedFixtures.Add(fixture);
}
}
}
_writer.WriteEndElement();
_writer.WriteStartElement("Bodies");
for (int i = 0; i < world.BodyList.Count; i++)
{
Body body = world.BodyList[i];
_bodies.Add(body);
SerializeBody(body);
}
_writer.WriteEndElement();
_writer.WriteStartElement("Joints");
for (int i = 0; i < world.JointList.Count; i++)
{
Joint joint = world.JointList[i];
SerializeJoint(joint);
}
_writer.WriteEndElement();
_writer.WriteEndElement();
_writer.Flush();
#if NETFX_CORE
_writer.Dispose();
#else
_writer.Close();
#endif
}
示例3: Diff
private bool Diff()
{
bool flag = false;
XmlWriterSettings xws = new XmlWriterSettings();
xws.ConformanceLevel = ConformanceLevel.Auto;
xws.CheckCharacters = false;
_Writer = XmlWriter.Create(new StringWriter(_Output), xws);
_Writer.WriteStartElement(String.Empty, "Root", String.Empty);
flag = CompareChildren(this._SourceDoc, this._TargetDoc);
_Writer.WriteEndElement();
_Writer.Dispose();
return flag;
}