當前位置: 首頁>>代碼示例>>C#>>正文


C# Message.WriteMessage方法代碼示例

本文整理匯總了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 ();
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:10,代碼來源:MessageTest.cs

示例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);
            }
開發者ID:JianwenSun,項目名稱:cc,代碼行數:38,代碼來源:TextMessageEncoder.cs

示例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));
            }
        }
開發者ID:JianwenSun,項目名稱:cc,代碼行數:37,代碼來源:MtomMessageEncoder.cs

示例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);
                }
            }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:60,代碼來源:JsonMessageEncoderFactory.cs

示例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);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:30,代碼來源:MtomMessageEncoder.cs


注:本文中的System.Globalization.Message.WriteMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。