public bool Serve(HttpContext context, PivotCollection collection, bool cacheToDisk) { if (collection == null) return false; CachePath = Path.GetDirectoryName(CachePath) + "\\" + collection.CollectionKey + ".cxml"; using (MemoryStream memoryStream = new MemoryStream()) { collection.ToCxml(memoryStream); memoryStream.Position = 0; // Rewind the stream, ready for reading memoryStream.WriteTo(context.Response.OutputStream); context.Response.ContentType = "text/xml"; if (cacheToDisk) CacheFile.Save(memoryStream, CachePath); } return true; }