当前位置: 首页>>代码示例>>C#>>正文


C# Message.ToString方法代码示例

本文整理汇总了C#中Message.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Message.ToString方法的具体用法?C# Message.ToString怎么用?C# Message.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Message的用法示例。


在下文中一共展示了Message.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateIncomingMessage

        private static string CreateIncomingMessage(Message request, string serviceName)
        {
            #region Aggregate Data

            var messageProperties = OperationContext.Current.IncomingMessageProperties;
            var remoteEndpointMessageProperty = messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
            var sourceAddress = remoteEndpointMessageProperty != null ? remoteEndpointMessageProperty.Address : m_Unknown;
            var sourcePort = remoteEndpointMessageProperty != null ? remoteEndpointMessageProperty.Port.ToString() : m_Unknown;
            
            var targetUri = request.Headers.To.ToString();

            var webOperationContext = WebOperationContext.Current;
            var method = webOperationContext != null ? webOperationContext.IncomingRequest.Method : m_Unknown;
            var authorizationKey = webOperationContext != null ? webOperationContext.IncomingRequest.Headers[HttpRequestHeader.Authorization] : null;

            #endregion

            #region Compose logging message

            var stringBuilder = new StringBuilder();

            stringBuilder.AppendLine();
            stringBuilder.AppendLine(string.Format("-------- Incoming message received on {0}. Details:", serviceName));
            stringBuilder.AppendLine(string.Format("Source address:           {0} ({1})", sourceAddress, sourcePort));
            stringBuilder.AppendLine(string.Format("Target URI:               {0}", targetUri));
            if (method != null) stringBuilder.AppendLine(string.Format("HTTP method:              {0}", method));
            if (authorizationKey != null) stringBuilder.AppendLine(string.Format("Authorization key:        {0}", authorizationKey));
            stringBuilder.AppendLine("Incoming Message:");
            stringBuilder.AppendLine(string.IsNullOrEmpty(request.ToString()) ? "<No incoming message>" : request.ToString());
            stringBuilder.AppendLine("--------");

            #endregion

            return stringBuilder.ToString();
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:35,代码来源:RestServiceLogging.cs

示例2: Handle

        public static void Handle(Message message, DofusClient client)
        {
            if (message.IsNull() && !client.IsNull())
            {
                Logger.Init2("[Rcv] Client " + client.SSyncClient.Ip + " send unknown datas, they wont be handled");
                return;
            }
            var handler = Handlers.FirstOrDefault(x => x.Key == message.MessageId);
            if (!handler.Value.IsNull())
            {
                {
                    if (ConfigurationManager.Instance.ShowProtocolMessages)
                        Logger.Write("[Rcv] Message: " + message.ToString(), ConsoleColor.Gray);
                    try
                    {

                        handler.Value.DynamicInvoke(null, message, client);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(string.Format("Unable to handle message {0} {1} : '{2}'", message.ToString(), handler.Value.Method.Name, ex.InnerException.ToString()));
                        ErrorLogsManager.AddLog(ex.InnerException.ToString(), client.SSyncClient.Ip);
                        client.SendRaw("forcedbugreport");
                    }
                }
            }
            else
            {
                if (ConfigurationManager.Instance.ShowProtocolMessages)
                    Logger.Log(string.Format("[Rcv] No Handler: ({0}) {1}", message.MessageId, message.ToString()));
            }
        }
开发者ID:thomasvinot,项目名称:Symbioz,代码行数:32,代码来源:MessagesHandler.cs

示例3: AfterReceiveReply

 /// <summary>
 /// Enables inspection or modification of a message after a reply message is received but prior to passing it back to the client application.
 /// </summary>
 /// <param name="reply">The message to be transformed into types and handed back to the client application.</param>
 /// <param name="correlationState">Correlation state data.</param>
 public void AfterReceiveReply( ref Message reply, object correlationState )
 {
     if( correlationState != null )
         this._logger.Trace( @"Response {{{0}}}:
     {1}", correlationState.ToString(), reply.ToString() );
     else
         this._logger.Trace( @"Response:
     {0}", reply.ToString() );
 }
开发者ID:slav,项目名称:Netco,代码行数:14,代码来源:LoggingInspector.cs

示例4: ReturnFriendlyDescription

            public void ReturnFriendlyDescription()
            {
                var id = Guid.NewGuid();
                var message = new Message<Object>(id, HeaderCollection.Empty, new Object());

                Assert.Equal($"{id} - System.Object", message.ToString());
            }
开发者ID:SparkSoftware,项目名称:infrastructure,代码行数:7,代码来源:MessageTests.cs

示例5: BeforeSendRequest

 public object BeforeSendRequest(
     ref Message request, 
     IClientChannel channel)
 {
     reqPayload = request.ToString();
     return null;
 }
开发者ID:oo00spy00oo,项目名称:Accelerators,代码行数:7,代码来源:MyEndpointBehavior.cs

示例6: AfterReceiveReply

        /// <summary>
        /// Called after response is received
        /// </summary>
        /// <param name="reply"></param>
        /// <param name="correlationState"></param>
        public void AfterReceiveReply(ref Message reply, object correlationState)
        {

            if (this.config.HttpHeaderLoggingEnabled)
            {
                //logging http headers
                HttpResponseMessageProperty httpResponse = reply.Properties[HttpResponseMessageProperty.Name] as HttpResponseMessageProperty;
                if (httpResponse != null && httpResponse.Headers != null && httpResponse.Headers.Count > 0)
                {
                    string httpHeaderMessage = "---[HTTP Response Headers]---\r\n";
                    foreach (string headerName in httpResponse.Headers.AllKeys)
                    {
                        httpHeaderMessage += headerName + " : " + httpResponse.Headers[headerName] + "\r\n";

                    }

                    //logger.Info(httpHeaderMessage);

                }
                else
                {
                    //logger.Info("HTTP Response Headers is not available!");
                }
            }

            if (this.config.SoapMessageLoggingEnabled)
            {
                //logging soap message
                string soapMessage = "receiving soap request message ...\r\n" + reply.ToString();
                //logger.Info(soapMessage);
            }

        }
开发者ID:craigshaw,项目名称:SoldOut,代码行数:38,代码来源:MessageInspector.cs

示例7: InformationalWithEnum

 public void InformationalWithEnum(Message message)
 {
     if (this.IsEnabled())
     {
         this.WriteEvent(1, message.ToString());
     }
 }
开发者ID:husains,项目名称:semantic-logging,代码行数:7,代码来源:MockEventSourceOutProcEnum.cs

示例8: BeforeSendRequest

 /// <summary>Enables inspection or modification of a message before a request message is sent to a service.</summary>
 /// <param name="request">The message to be sent to the service.</param>
 /// <param name="channel">The  client object channel.</param>
 /// <returns>
 /// The object that is returned as the <c>correlationState</c> argument of the <see cref="M:System.ServiceModel.Dispatcher.IClientMessageInspector.AfterReceiveReply([email protected],System.Object)"/> method. This is null if no correlation state is used.The best practice is to make this a <see cref="T:System.Guid"/> to ensure that no two <c>correlationState</c> objects are the same.
 /// </returns>
 public object BeforeSendRequest( ref Message request, IClientChannel channel )
 {
     var correlationState = Guid.NewGuid();
     this._logger.Trace( @"Request {{{0}}}:
     {1}", correlationState.ToString(), request.ToString() );
     return correlationState;
 }
开发者ID:slav,项目名称:Netco,代码行数:13,代码来源:LoggingInspector.cs

示例9: AfterReceiveRequest

 public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
 {
     var logger = ObjectFactory.GetInstance<ILogger>();
     logger.StartAction(request.Headers.To.ToString());
     logger.Write("Incoming Message", request.ToString());
     return null;
 }
开发者ID:josh28,项目名称:TaskMaster,代码行数:7,代码来源:CustomMessageInspector.cs

示例10: Main

        /// <summary>
        /// This is a simple demonstration of zeroMQ sockets using netMQ and protocol-buffer  
        /// This code demonstrates two things
        /// 
        /// 1. Use of zeroMQ REQUEST-RESPONSE socket using NetMQ library
        /// 2. Serialization and Deserialization using protocol-buf library
        /// 
        /// NOTE: Request-Response pattern is strictly sequential
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            const string serverAddress = "tcp://localhost:5556";
            const string serverIdentifier = "Response Server";

            using (var context = NetMQContext.Create())
            using (var server = context.CreateResponseSocket())
            using (var client = context.CreateRequestSocket())
            {
                // Bind the server to a local TCP address
                // Server is the stable infrastructure and that should BIND
                server.Bind(serverAddress);

                // Connect the client to the server. Client is dynamic so it CONNECTs to the address
                client.Connect(serverAddress);

                {
                    var clientMsg = new Message();
                    clientMsg.initMessage("Request Client1", serverIdentifier, "hello", "getting introduced");
                    Console.WriteLine("Client sending message: {0}", clientMsg.ToString());

                    // Send a message from the client socket
                    client.SendFrame(clientMsg.Serialize());
                }

                // Receive the message from the server socket
                {
                    byte[] rawmsg = server.ReceiveFrameBytes();
                    if (rawmsg != null && rawmsg.Length > 0)
                    {
                        var receivedMsg = Message.Deserialize(rawmsg);
                        Console.WriteLine("Server Received Message From Client: {0}", receivedMsg.ToString());

                        var serverMsg = new Message();
                        serverMsg.initMessage(serverIdentifier, receivedMsg.Source, "hello " + receivedMsg.Source, "Server has a new connection!");

                        Console.WriteLine("Server sending message: {0}", serverMsg.ToString());
                        // Send a response back from the server
                        server.SendFrame(serverMsg.Serialize());

                    }

                }

                // Now client should receive the message
                {
                    byte[] rawmsg = client.ReceiveFrameBytes();
                    if (rawmsg != null && rawmsg.Length > 0)
                    {

                        var receivedMsg = Message.Deserialize(rawmsg);
                        Console.WriteLine("Message From Server: {0}", receivedMsg.ToString());
                    }
                }

                Console.WriteLine("Press any key to exit ...");
                Console.ReadKey();
            }
        }
开发者ID:bbcCorp,项目名称:NetMQDemo,代码行数:69,代码来源:Program.cs

示例11: BeforeSendReply

 public void BeforeSendReply(ref Message reply, object correlationState)
 {
     Console.ForegroundColor = ConsoleColor.Green;
     Console.WriteLine(
         "{0:HH:mm:ss.ffff}\t{1}\n\t\t{2} ({3} bytes)",
         DateTime.Now, reply.Headers.RelatesTo, reply.Headers.Action,
         reply.ToString().Length);
 }
开发者ID:urmilaNominate,项目名称:mERP-framework,代码行数:8,代码来源:MonitorBehavior.cs

示例12: BeforeSendRequest

        public object BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            Console.WriteLine( "Sending the following request: '{0}'", request.ToString());

            LogMessage("BeforeSendRequest", request);
            
            return null;
        }
开发者ID:gtkrug,项目名称:gfipm-ws-ms.net,代码行数:8,代码来源:CommercialVehicleMessageInspector.cs

示例13: Send

 public void Send(string name, params object[] args)
 {
     var msg = new Message (name, args);
     msg.type = "ev";
     if (SendHook != null)
         SendHook (this, msg);
     ws.Send (msg.ToString ());
 }
开发者ID:simonwittber,项目名称:netwrok-client,代码行数:8,代码来源:Connection.cs

示例14: Invoke

 protected void Invoke(Message message, bool closeGallery)
 {
     Assert.ArgumentNotNull((object)message, "message");
     SheerResponse.Eval("scForm.getParentForm().invoke(\"" + StringUtil.EscapeBackslash(message.ToString()) + "\")");
     if (!closeGallery)
         return;
     SheerResponse.Eval("scForm.getParentForm().Content.closeGallery(scForm.browser.getFrameElement().id)");
 }
开发者ID:TwentyGotoTen,项目名称:ManualHtmlCacheClearer,代码行数:8,代码来源:HtmlCachesGallery.cs

示例15: AfterReceiveRequest

        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            if (string.IsNullOrEmpty(request.ToString()))
            {
                return null;
            }

            var envoltorio = new EnvoltorioMensaje
            {
                FechaInicio = DateTime.Now,
                Request = request.ToString(),
                Accion = request.Headers.Action,
                Ip = OperationContext.Current.ObtnerIp()
            };
            
            return envoltorio;
        }
开发者ID:berczeck,项目名称:.Net,代码行数:17,代码来源:InspectorServicio.cs


注:本文中的Message.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。