/// <summary> /// Gets service document in xml string format. /// </summary> /// <param name="serviceDocument">service document to be convert.</param> /// <returns>Service document xml string</returns> protected static string GetServiceDocument(ServiceDocument serviceDocument) { XmlWriter writer = null; MemoryStream serviceDocStream = new MemoryStream(); StreamReader reader = null; try { writer = XmlWriter.Create(serviceDocStream); serviceDocument.Save(writer); serviceDocStream.Seek(0, SeekOrigin.Begin); reader = new StreamReader(serviceDocStream); return(reader.ReadToEnd()); } finally { if (null != writer) { writer.Close(); } if (null != reader) { reader.Close(); } if (null != serviceDocStream) { serviceDocStream.Close(); } } }
public void Save () { var v = new ServiceDocument (); var sw = new StringWriter (); using (var xw = XmlWriter.Create (sw, settings)) v.Save (xw); Assert.AreEqual ("<app:service xmlns:a10=\"http://www.w3.org/2005/Atom\" xmlns:app=\"http://www.w3.org/2007/app\" />", sw.ToString ()); }
public void Save() { var v = new ServiceDocument(); var sw = new StringWriter(); using (var xw = XmlWriter.Create(sw, settings)) v.Save(xw); Assert.AreEqual("<app:service xmlns:a10=\"http://www.w3.org/2005/Atom\" xmlns:app=\"http://www.w3.org/2007/app\" />", sw.ToString()); }