Example #1
0
        /// <summary>
        /// Traces the response.
        /// </summary>
        /// <param name="response">The response.</param>
        /// <param name="memoryStream">The response content in a MemoryStream.</param>
        private void TraceResponse(HttpWebResponse response, MemoryStream memoryStream)
        {
            EwsUtilities.Assert(
                memoryStream != null,
                "WindowsLiveCredentials.TraceResponse",
                "memoryStream cannot be null");

            if (!this.TraceEnabled)
            {
                return;
            }

            if (!string.IsNullOrEmpty(response.ContentType) &&
                (response.ContentType.StartsWith("text/", StringComparison.OrdinalIgnoreCase) ||
                 response.ContentType.StartsWith("application/soap", StringComparison.OrdinalIgnoreCase)))
            {
                this.traceListener.Trace(
                    "WindowsLiveResponse",
                    EwsUtilities.FormatLogMessageWithXmlContent("WindowsLiveResponse", memoryStream));
            }
            else
            {
                this.traceListener.Trace(
                    "WindowsLiveResponse",
                    "Non-textual response");
            }
        }
 /// <summary>
 /// Logs the specified XML to the TraceListener if tracing is enabled.
 /// </summary>
 /// <param name="traceType">Kind of trace entry.</param>
 /// <param name="stream">The stream containing XML.</param>
 internal void TraceXml(TraceFlags traceType, MemoryStream stream)
 {
     if (this.IsTraceEnabledFor(traceType))
     {
         string traceTypeStr = traceType.ToString();
         string logMessage   = EwsUtilities.FormatLogMessageWithXmlContent(traceTypeStr, stream);
         this.TraceListener.Trace(traceTypeStr, logMessage);
     }
 }