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


C# Message类代码示例

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


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

示例1: PromoteException

        //Can only be called inside a service
        public static void PromoteException(Exception error,MessageVersion version,ref Message fault)
        {
            StackFrame frame = new StackFrame(1);

             Type serviceType = frame.GetMethod().ReflectedType;
             PromoteException(serviceType,error,version,ref fault);
        }
开发者ID:JMnITup,项目名称:SMEX,代码行数:8,代码来源:ErrorHandlerHelper.cs

示例2: handleMessage

        // DeckList && LibraryView
        public void handleMessage(Message msg)
        {
            if( msg is LibraryViewMessage && config.ContainsKey("user-id") ) {
                LibraryViewMessage viewMsg = (LibraryViewMessage) msg;
                if( !viewMsg.profileId.Equals(App.MyProfile.ProfileInfo.id) ) {
                    return;
                }

                inventoryCards.Clear();
                foreach( Card card in viewMsg.cards ) {
                    inventoryCards[card.id] = String.Format("{0},{1}", card.typeId, card.tradable ? 1 : 0);
                }

                if( dataPusher == null ) {
                    if( config.ContainsKey("last-card-sync") ) {
                        dataPusher = new Thread(new ThreadStart(DelayedPush));
                    } else {
                        dataPusher = new Thread(new ThreadStart(Push));
                    }

                    dataPusher.Start();
                }

            //} else if( msg is DeckCardsMessage ) {
            //    DeckCardsMessage deckMsg = (DeckCardsMessage)msg;
            //} else if( msg is DeckSaveMessage ) {
            }
        }
开发者ID:noHero123,项目名称:ScrollsPost,代码行数:29,代码来源:CollectionSync.cs

示例3: SendEvent

 // Create a message and send it to IoT Hub.
 async Task SendEvent(string power)
 {
     string dataBuffer;
     dataBuffer = power;
     Message eventMessage = new Message(Encoding.UTF8.GetBytes(dataBuffer));
     await deviceClient.SendEventAsync(eventMessage);
 }
开发者ID:aevansnet,项目名称:MorningDashboard,代码行数:8,代码来源:PowerMonitorViewModel.cs

示例4: BeforeSendRequest

        /// <summary>
        /// Add token message at header to using NHibernate cache
        /// </summary>
        /// <param name="request"></param>
        /// <param name="channel"></param>
        /// <returns></returns>
        public object BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            // add trace log for debug and performance tuning
            if (null != (request.Headers).MessageId && (request.Headers).MessageId.IsGuid)
            {
                ServiceStopWatch = Stopwatch.StartNew();
                Guid messageId;
                (request.Headers).MessageId.TryGetGuid(out messageId);

                CurrentTraceInfo = new TraceInfo()
                {
                    SessionId = (HttpContext.Current != null && HttpContext.Current.Session != null) ? HttpContext.Current.Session.SessionID : "",
                    TraceType = TraceType.WcfActionClientCall,
                    TraceName = request.Headers.Action,
                    TraceUniqueId = messageId.ToString()
                };

                TraceLogger.Instance.TraceServiceStart(CurrentTraceInfo, true);

                // Add a message header with sessionid
                MessageHeader<string> messageHeader = new MessageHeader<string>(CurrentTraceInfo.SessionId);
                MessageHeader untyped = messageHeader.GetUntypedHeader("sessionid", "ns");
                request.Headers.Add(untyped);
            }
            return null;
        }
开发者ID:VKeCRM,项目名称:V2,代码行数:32,代码来源:TraceClientMessageInspector.cs

示例5: AfterReceiveRequest

        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            bool shouldCompressResponse = false;

            object propObj;
            if (request.Properties.TryGetValue(HttpRequestMessageProperty.Name, out propObj))
            {
                var prop = (HttpRequestMessageProperty)propObj;
                var accept = prop.Headers[HttpRequestHeader.Accept];
                if (accept != null)
                {
                    if (jsonContentTypes.IsMatch(accept))
                    {
                        WebOperationContext.Current.OutgoingResponse.Format = WebMessageFormat.Json;
                    }
                    else if (xmlContentTypes.IsMatch(accept))
                    {
                        WebOperationContext.Current.OutgoingResponse.Format = WebMessageFormat.Xml;
                    }
                }

                var acceptEncoding = prop.Headers[HttpRequestHeader.AcceptEncoding];
                if (acceptEncoding != null && acceptEncoding.Contains("gzip"))
                {
                    shouldCompressResponse = true;
                }
            }

            return shouldCompressResponse;
        }
开发者ID:carlosfigueira,项目名称:WCFSamples,代码行数:30,代码来源:CompressionAndFormatSelectionMessageInspector.cs

示例6: ParseMessage

        /// <summary>
        /// Parses the JSON message from Amazon SNS into the Message object.
        /// </summary>
        /// <param name="messageText">The JSON text from an Amazon SNS message</param>
        /// <returns>The Message object with properties set from the JSON document</returns>
        public static Message ParseMessage(string messageText)
        {
            var message = new Message();

            var jsonData = JsonMapper.ToObject(messageText);

            Func<string, string> extractField = ((fieldName) =>
                {
                    if (jsonData[fieldName] != null && jsonData[fieldName].IsString)
                        return (string)jsonData[fieldName];
                    return null;
                });

            message.MessageId = extractField("MessageId");
            message.MessageText = extractField("Message");
            message.Signature = extractField("Signature");
            message.SignatureVersion = extractField("SignatureVersion");
            message.SigningCertURL = ValidateCertUrl(extractField("SigningCertURL"));
            message.SubscribeURL = extractField("SubscribeURL");
            message.Subject = extractField("Subject");
            message.TimestampString = extractField("Timestamp");
            message.Token = extractField("Token");
            message.TopicArn = extractField("TopicArn");
            message.Type = extractField("Type");
            message.UnsubscribeURL = extractField("UnsubscribeURL");

            return message;
        }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:33,代码来源:Message.cs

示例7: AddMessage

 public static int AddMessage(Message obj)
 {
     int result;
     TMSDataLibrary.Message objMsg = new TMSDataLibrary.Message();
     result = objMsg.AddMessege(obj.BookingId, obj.ToId, obj.FromId, obj.Messagee);
     return result;
 }
开发者ID:mzrokz,项目名称:LssTms,代码行数:7,代码来源:MessageMethods.cs

示例8: AfterReceiveRequest

 public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
 {
     var reply = request.Headers.ReplyTo;
     OperationContext.Current.OutgoingMessageHeaders.To = reply.Uri;
     OperationContext.Current.OutgoingMessageHeaders.RelatesTo = request.Headers.MessageId;
     return null;
 }
开发者ID:ronybot,项目名称:MessageBus,代码行数:7,代码来源:ReplyToBehavior.cs

示例9: CreateSlackMessage

        public static Message CreateSlackMessage(string text, IEnumerable<AttachmentField> fields, BotElement bot, string channel, string color, bool asUser)
        {
            if (text == null) return null;
            IEnumerable<Attachment> attachments = null;
            if (fields != null && fields.Any())
            {
                attachments = new[] {
                    new Attachment() {
                        Fallback = text,
                        Color = color,
                        Fields = fields
                    }
                };
            }
            var message = new Message()
            {
                Channel = channel,
                Text = text,
                Attachments = attachments
            };

            if (!asUser)
            {
                message.Username = bot.GetSetting("username");
                if (!string.IsNullOrEmpty(bot.GetSetting("iconUrl")))
                    message.IconUrl = bot.GetSetting("iconUrl");
                else if (!string.IsNullOrEmpty(bot.GetSetting("iconEmoji")))
                    message.IconEmoji = bot.GetSetting("iconEmoji");
            }

            return message;
        }
开发者ID:kria,项目名称:TfsNotificationRelay,代码行数:32,代码来源:SlackHelper.cs

示例10: HotkeyMessage

 public HotkeyMessage(Message messageType, Level messageLevel, IntPtr hWnd, int Data)
 {
     Message = messageType;
     level = messageLevel;
     handle = hWnd;
     data = Data;
 }
开发者ID:Phoshi,项目名称:TWiME,代码行数:7,代码来源:HotkeyMessage.cs

示例11: FormattedMessage

		private void FormattedMessage(Message message, char format, StringBuilder output)
		{
			using (var writer = CreateWriter(message, format, output))
			{
				switch (format)
				{
					case 'b':
						message.WriteBody(writer);
						break;
					case 'B':
						message.WriteBodyContents(writer);
						break;
					case 's':
						message.WriteStartBody(writer);
						break;
					case 'S':
						message.WriteStartEnvelope(writer);
						break;
					case 'm':
					case 'M':
						message.WriteMessage(writer);
						break;
					default:
						return;
				}

				writer.Flush();
			}
		}
开发者ID:ralescano,项目名称:castle,代码行数:29,代码来源:CustomMessageFormatter.cs

示例12: FormattedHeaders

		private void FormattedHeaders(Message message, StringBuilder output)
		{
			foreach (var header in message.Headers)
			{
				output.AppendFormat("\n{0}\n", header);
			}
		}
开发者ID:ralescano,项目名称:castle,代码行数:7,代码来源:CustomMessageFormatter.cs

示例13: Should_not_overwrite_correlation_id

        public void Should_not_overwrite_correlation_id()
        {
            var autoResetEvent = new AutoResetEvent(false);
            const string expectedCorrelationId = "abc_foo";
            var actualCorrelationId = "";

            var queue = EasyNetQ.Topology.Queue.DeclareDurable("myqueue");
            var exchange = EasyNetQ.Topology.Exchange.DeclareDirect("myexchange");
            queue.BindTo(exchange, "#");
            bus.Subscribe<MyMessage>(queue, (message, info) => Task.Factory.StartNew(() =>
            {
                actualCorrelationId = message.Properties.CorrelationId;
                autoResetEvent.Set();
            }));

            var messageToSend = new Message<MyMessage>(new MyMessage());
            messageToSend.Properties.CorrelationId = expectedCorrelationId;

            using (var channel = bus.OpenPublishChannel())
            {
                channel.Publish(exchange, "abc", messageToSend);
            }

            autoResetEvent.WaitOne(1000);

            actualCorrelationId.ShouldEqual(expectedCorrelationId);
        }
开发者ID:nslowes,项目名称:EasyNetQ,代码行数:27,代码来源:AdvancedPublishSubscribeTests.cs

示例14: CheckAccess

        public override bool CheckAccess(OperationContext operationContext, ref Message message)
        {
            // Open the request message using an xml reader
            XmlReader xr = OperationContext.Current.IncomingMessageHeaders.GetReaderAtHeader(0);

                // Split the URL at the API name--Parameters junction indicated by the '?' character - taking the first string will ignore all parameters
                string[] urlSplit = xr.ReadElementContentAsString().Split('/');
                // Extract just the API name and rest of the URL, which will be the last item in the split using '/'
                string[] apiSplit = urlSplit[3].Split('?');
                // Logging the username and API name
                Tracer.WriteUserLog(apiSplit[0] + " request from user: " + operationContext.ServiceSecurityContext.WindowsIdentity.Name);

            // If the most-privileged-role that this user belongs has access to this api, then allow access, otherwise deny access
            // Returning true will allow the user to execute the actual API function; Returning false will deny access to the user
            if (ChassisManagerSecurity.GetCurrentUserMostPrivilegedRole() <= ChassisManagerSecurity.GetCurrentApiLeastPrivilegedRole(apiSplit[0]))
            {
                Tracer.WriteUserLog("CheckAccess: Authorized");
                return true;
            }
            else
            {
                Tracer.WriteUserLog("CheckAccess: NOT Authorized");
                return false;
            }
        }
开发者ID:kewencai,项目名称:ChassisManager,代码行数:25,代码来源:ChassisManagerSecurity.cs

示例15: OnClick

    public void OnClick(string name )
    {
        Debug.Log("Click " + name );
        Message msg = new Message();
        msg.AddMessage("name", name);
        EventManager.Instance.PostEvent(EventDefine.TL_PRESS_BUTTON, msg);

        if (name == "Cone")
        {
            SpriteAction sa = coneEffect.GetComponent<SpriteAction>();
            SpriteRenderer render = coneEffect.GetComponent<SpriteRenderer>();

            render.color = new Color(Random.Range(0.5f , 1f) , Random.Range(0.5f , 1f) , Random.Range(0.5f , 1f) , 0.5f );
            sa.Do();
        }
        if (name == "Bubble")
        {
            bubbleEffect.enableEmission = true;
        }
        if (name == "Flower")
        {
            AudioSource[] audios = flowerEffect.GetComponents<AudioSource>();
            audios[Random.Range(0, audios.Length)].Play();
        }
    }
开发者ID:fdu5526,项目名称:balloon,代码行数:25,代码来源:SceneTL.cs


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