Example #1
0
        static Stream CreateTraceXml()
        {
            MemoryStream result = null;
            MemoryStream ms     = null;

            try
            {
                ms = new MemoryStream();
                using (XmlWriter writer = XmlWriter.Create(ms, new XmlWriterSettings {
                    OmitXmlDeclaration = true
                }))
                {
                    writer.WriteStartElement("Traces");
                    foreach (XElement element in InMemoryTraceListener.GetEntries())
                    {
                        element.WriteTo(writer);
                    }
                    writer.WriteEndElement();
                }
                ms.Seek(0, SeekOrigin.Begin);

                result = ms;
                ms     = null;
            }
            finally
            {
                if (ms != null)
                {
                    ms.Dispose();
                }
            }
            return(result);
        }
Example #2
0
        static SyndicationFeed CreateTraceSyndicationFeed()
        {
            IEnumerable <SyndicationItem> items = from entry in InMemoryTraceListener.GetEntries()
                                                  select CreateTraceSyndicationItem(entry);

            SyndicationFeed feed = new SyndicationFeed(items);

            feed.Title = new TextSyndicationContent(Resx.WCFTraceFeedTitle);
            return(feed);
        }
Example #3
0
        static Stream CreateTraceHtml()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(string.Format(CultureInfo.InvariantCulture, "<html><head><title>{0}</title></head><body style=\"font-family: sans-serif\"><h1>{0}</h1>", Resx.WCFTraceFeedTitle));
            IEnumerable <string> items = from entry in InMemoryTraceListener.GetEntries()
                                         select CreateTraceHtmlEntry(entry);

            foreach (string item in items)
            {
                sb.Append(item);
            }
            sb.Append("</body></html>");
            return(new MemoryStream(Encoding.UTF8.GetBytes(sb.ToString())));
        }