#region Disclaimer / License // Copyright (C) 2011, Jackie Ng // http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie@gmail.com // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // #endregion using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using OSGeo.MapGuide; using System.Xml; using System.IO; namespace Maestro.AddIn.Local.UI { public partial class ConnectionPoolStatusDialog : Form { private ConnectionPoolStatusDialog() { InitializeComponent(); } public ConnectionPoolStatusDialog(MgByteReader reader) : this() { txtXml.Text = FormatXml(reader.ToString()); } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } private string FormatXml(string sUnformattedXml) { //load unformatted xml into a dom XmlDocument xd = new XmlDocument(); xd.LoadXml(sUnformattedXml); //will hold formatted xml StringBuilder sb = new StringBuilder(); //pumps the formatted xml into the StringBuilder above StringWriter sw = new StringWriter(sb); //does the formatting XmlTextWriter xtw = null; try { //point the xtw at the StringWriter xtw = new XmlTextWriter(sw); //we want the output formatted xtw.Formatting = Formatting.Indented; //get the dom to dump its contents into the xtw xd.WriteTo(xtw); } finally { //clean up even if error if (xtw != null) xtw.Close(); } //return the formatted xml return sb.ToString(); } } }