本文整理汇总了C#中System.Globalization.Message.WriteMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Message.WriteMessage方法的具体用法?C# Message.WriteMessage怎么用?C# Message.WriteMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.Message
的用法示例。
在下文中一共展示了Message.WriteMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSerializedMessage
public static string GetSerializedMessage (Message msg)
{
StringWriter sw = new StringWriter ();
XmlWriterSettings settings = new XmlWriterSettings ();
settings.OmitXmlDeclaration = true;
using (XmlWriter xw = XmlWriter.Create (sw, settings)) {
msg.WriteMessage (xw);
}
return sw.ToString ();
}
示例2: WriteMessage
public override void WriteMessage(Message message, Stream stream)
{
if (message == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("message"));
if (stream == null)
throw TraceUtility.ThrowHelperError(new ArgumentNullException("stream"), message);
ThrowIfMismatchedMessageVersion(message);
EventTraceActivity eventTraceActivity = null;
if (TD.TextMessageEncodingStartIsEnabled())
{
eventTraceActivity = EventTraceActivityHelper.TryExtractActivity(message);
TD.TextMessageEncodingStart(eventTraceActivity);
}
message.Properties.Encoder = this;
XmlDictionaryWriter xmlWriter = TakeStreamedWriter(stream);
if (optimizeWriteForUTF8)
{
message.WriteMessage(xmlWriter);
}
else
{
xmlWriter.WriteStartDocument();
message.WriteMessage(xmlWriter);
xmlWriter.WriteEndDocument();
}
xmlWriter.Flush();
ReturnStreamedWriter(xmlWriter);
if (TD.StreamedMessageWrittenByEncoderIsEnabled())
{
TD.StreamedMessageWrittenByEncoder(eventTraceActivity ?? EventTraceActivityHelper.TryExtractActivity(message));
}
if (MessageLogger.LogMessagesAtTransportLevel)
MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportSend);
}
示例3: WriteMessage
void WriteMessage(Message message, Stream stream, string startInfo, string boundary, string startUri, bool writeMessageHeaders)
{
if (message == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("message"));
if (stream == null)
throw TraceUtility.ThrowHelperError(new ArgumentNullException("stream"), message);
ThrowIfMismatchedMessageVersion(message);
EventTraceActivity eventTraceActivity = null;
if (TD.MtomMessageEncodingStartIsEnabled())
{
eventTraceActivity = EventTraceActivityHelper.TryExtractActivity(message);
TD.MtomMessageEncodingStart(eventTraceActivity);
}
message.Properties.Encoder = this;
if (MessageLogger.LogMessagesAtTransportLevel)
MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportSend);
XmlDictionaryWriter xmlWriter = TakeStreamedWriter(stream, startInfo, boundary, startUri, writeMessageHeaders);
if (this.writeEncoding.WebName == "utf-8")
{
message.WriteMessage(xmlWriter);
}
else
{
xmlWriter.WriteStartDocument();
message.WriteMessage(xmlWriter);
xmlWriter.WriteEndDocument();
}
xmlWriter.Flush();
ReturnStreamedWriter(xmlWriter);
if (TD.StreamedMessageWrittenByEncoderIsEnabled())
{
TD.StreamedMessageWrittenByEncoder(eventTraceActivity ?? EventTraceActivityHelper.TryExtractActivity(message));
}
}
示例4: WriteMessage
public override void WriteMessage(Message message, Stream stream)
{
if (message == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("message"));
}
if (stream == null)
{
throw TraceUtility.ThrowHelperError(new ArgumentNullException("stream"), message);
}
ThrowIfMismatchedMessageVersion(message);
EventTraceActivity eventTraceActivity = null;
if (WebTD.JsonMessageEncodingStartIsEnabled())
{
eventTraceActivity = EventTraceActivityHelper.TryExtractActivity(message);
WebTD.JsonMessageEncodingStart(eventTraceActivity);
}
message.Properties.Encoder = this;
XmlDictionaryWriter xmlWriter = TakeStreamedWriter(stream);
JavascriptCallbackResponseMessageProperty javascriptResponseMessageProperty;
if (message.Properties.TryGetValue<JavascriptCallbackResponseMessageProperty>(JavascriptCallbackResponseMessageProperty.Name, out javascriptResponseMessageProperty)
&& javascriptResponseMessageProperty != null
&& !String.IsNullOrEmpty(javascriptResponseMessageProperty.CallbackFunctionName))
{
if (!this.crossDomainScriptAccessEnabled)
{
throw TraceUtility.ThrowHelperError(new InvalidOperationException(SR2.JavascriptCallbackNotEnabled), message);
}
byte[] buffer = this.writeEncoding.GetBytes(String.Format(CultureInfo.InvariantCulture, "{0}(", javascriptResponseMessageProperty.CallbackFunctionName));
stream.Write(buffer, 0, buffer.Length);
}
xmlWriter.WriteStartDocument();
message.WriteMessage(xmlWriter);
xmlWriter.WriteEndDocument();
xmlWriter.Flush();
ReturnStreamedWriter(xmlWriter);
if (javascriptResponseMessageProperty != null
&& !String.IsNullOrEmpty(javascriptResponseMessageProperty.CallbackFunctionName))
{
if (javascriptResponseMessageProperty.StatusCode != null && (int)javascriptResponseMessageProperty.StatusCode != 200)
{
byte[] buffer = this.writeEncoding.GetBytes(String.Format(CultureInfo.InvariantCulture, ",{0}", (int)javascriptResponseMessageProperty.StatusCode));
stream.Write(buffer, 0, buffer.Length);
}
stream.Write(this.encodedClosingFunctionCall, 0, this.encodedClosingFunctionCall.Length);
}
if (SMTD.StreamedMessageWrittenByEncoderIsEnabled())
{
SMTD.StreamedMessageWrittenByEncoder(
eventTraceActivity ?? EventTraceActivityHelper.TryExtractActivity(message));
}
if (MessageLogger.LogMessagesAtTransportLevel)
{
MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportSend);
}
}
示例5: WriteMessage
private void WriteMessage(Message message, Stream stream, string startInfo, string boundary, string startUri, bool writeMessageHeaders)
{
if (message == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("message"));
}
if (stream == null)
{
throw TraceUtility.ThrowHelperError(new ArgumentNullException("stream"), message);
}
base.ThrowIfMismatchedMessageVersion(message);
message.Properties.Encoder = this;
if (MessageLogger.LogMessagesAtTransportLevel)
{
MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportSend);
}
XmlDictionaryWriter writer = this.TakeStreamedWriter(stream, startInfo, boundary, startUri, writeMessageHeaders);
if (this.writeEncoding.WebName == "utf-8")
{
message.WriteMessage(writer);
}
else
{
writer.WriteStartDocument();
message.WriteMessage(writer);
writer.WriteEndDocument();
}
writer.Flush();
this.ReturnStreamedWriter(writer);
}