private void Clear() { _memoryStream = null; _uriPhpStream?.Dispose(); _uriPhpStream = null; _writer?.Dispose(); _writer = null; }
void IDisposable.Dispose() { if (_writer != null) { _writer.Dispose(); _writer = null; } }
private void Clear() { _memoryStream = null; _uriPhpStream?.Dispose(); _uriPhpStream = null; _writer?.Dispose(); _writer = null; _state = new Stack <State>(2); _dtdStart = false; _unclosedNodesCount = 0; }
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 }
public override void Close() { _writer.Dispose(); }
void IDisposable.Dispose() { _writer?.Dispose(); _writer = null; }
private void ReturnStreamedWriter(XmlWriter xmlWriter) { Contract.Assert(xmlWriter != null, "xmlWriter MUST NOT be null"); xmlWriter.Flush(); xmlWriter.Dispose(); }
public void Dispose() { _writer.Dispose(); Clear(); }
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; }
public static void CloseWriter(System.Xml.XmlWriter writer) { writer.WriteEndElement(); writer.WriteEndDocument(); writer.Dispose(); }
public void Dispose() { _writer?.Dispose(); _writer = null; }
public void EventsToWriter(XmlWriter writer) { if (this.singleText.Count != 0) { writer.WriteString(this.singleText.GetResult()); } else { XmlRawWriter writer2 = writer as XmlRawWriter; for (int i = 0; i < this.pages.Count; i++) { XmlEvent[] eventArray = this.pages[i]; for (int j = 0; j < eventArray.Length; j++) { byte[] buffer; switch (eventArray[j].EventType) { case XmlEventType.Unknown: return; case XmlEventType.DocType: { writer.WriteDocType(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3, (string)eventArray[j].Object); continue; } case XmlEventType.StartElem: { writer.WriteStartElement(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3); continue; } case XmlEventType.StartAttr: { writer.WriteStartAttribute(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3); continue; } case XmlEventType.EndAttr: { writer.WriteEndAttribute(); continue; } case XmlEventType.CData: { writer.WriteCData(eventArray[j].String1); continue; } case XmlEventType.Comment: { writer.WriteComment(eventArray[j].String1); continue; } case XmlEventType.PI: { writer.WriteProcessingInstruction(eventArray[j].String1, eventArray[j].String2); continue; } case XmlEventType.Whitespace: { writer.WriteWhitespace(eventArray[j].String1); continue; } case XmlEventType.String: { writer.WriteString(eventArray[j].String1); continue; } case XmlEventType.Raw: { writer.WriteRaw(eventArray[j].String1); continue; } case XmlEventType.EntRef: { writer.WriteEntityRef(eventArray[j].String1); continue; } case XmlEventType.CharEnt: { writer.WriteCharEntity((char)eventArray[j].Object); continue; } case XmlEventType.SurrCharEnt: { char[] chArray = (char[])eventArray[j].Object; writer.WriteSurrogateCharEntity(chArray[0], chArray[1]); continue; } case XmlEventType.Base64: { buffer = (byte[])eventArray[j].Object; writer.WriteBase64(buffer, 0, buffer.Length); continue; } case XmlEventType.BinHex: { buffer = (byte[])eventArray[j].Object; writer.WriteBinHex(buffer, 0, buffer.Length); continue; } case XmlEventType.XmlDecl1: { if (writer2 != null) { writer2.WriteXmlDeclaration((XmlStandalone)eventArray[j].Object); } continue; } case XmlEventType.XmlDecl2: { if (writer2 != null) { writer2.WriteXmlDeclaration(eventArray[j].String1); } continue; } case XmlEventType.StartContent: { if (writer2 != null) { writer2.StartElementContent(); } continue; } case XmlEventType.EndElem: { if (writer2 == null) { break; } writer2.WriteEndElement(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3); continue; } case XmlEventType.FullEndElem: { if (writer2 == null) { goto Label_0367; } writer2.WriteFullEndElement(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3); continue; } case XmlEventType.Nmsp: { if (writer2 == null) { goto Label_0394; } writer2.WriteNamespaceDeclaration(eventArray[j].String1, eventArray[j].String2); continue; } case XmlEventType.EndBase64: { if (writer2 != null) { writer2.WriteEndBase64(); } continue; } case XmlEventType.Close: { writer.Close(); continue; } case XmlEventType.Flush: { writer.Flush(); continue; } case XmlEventType.Dispose: { writer.Dispose(); continue; } default: { continue; } } writer.WriteEndElement(); continue; Label_0367: writer.WriteFullEndElement(); continue; Label_0394: writer.WriteAttributeString("xmlns", eventArray[j].String1, "http://www.w3.org/2000/xmlns/", eventArray[j].String2); } } } }