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


C# IMessage.GetType方法代码示例

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


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

示例1: SendMessage

 public void SendMessage(object sender, IMessage message, object context = null)
 {
     StartAction(() =>
     {
         if (sender != null)
         {
             if (_dictionary.ContainsKey(message.GetType()))
             {
                 foreach (var actionInfo in _dictionary[message.GetType()])
                 {
                     if (context != null)
                     {
                         if (actionInfo.Context == context)
                         {
                             actionInfo.Handler.Invoke();
                         }
                     }
                     else
                     {
                         actionInfo.Handler.Invoke();
                     }
                 }
             }
         }
     });
 }
开发者ID:ArturR89,项目名称:WPFApplication,代码行数:26,代码来源:Mediator.cs

示例2: HandleMessage

        /// <summary>
        /// Accepts IMessage's sent to the GRoup
        /// </summary>
        /// <param name="message"></param>
        /// <returns>true if successfully broadcasted to RelationshipType.MEMBER's</returns>
        /// <remarks>
        /// Overrides the default HandleMessage Behaviour for Group-like behaviour
        /// </remarks>
        public override bool HandleMessage(IMessage message)
        {
            // Check the message type
            if (message.GetType() == typeof(StringMessage))
            {
                // pass the message on
                Relationship members = new Relationship(RelationshipType.MEMBER);
                // broadcast the message using Graph methods
                Connections.Instance.SendMessageTo(this, members, message);
                return true;
            }

            // if it's a connection message, try to learn about the connection
            if (message.GetType() == typeof(ConnectionMessage))
            {
                // convert the message
                ConnectionMessage msg = message as ConnectionMessage;
                // pass the message
                Learn(msg.Connection);

                return true;
            }

            // didn't do anything.
            return false;
        }
开发者ID:pandaboy,项目名称:RelationshipGraph,代码行数:34,代码来源:GroupEntity.cs

示例3: GetConditionsForMessage

		/// <summary>
		/// Gets the list of conditions associated with a message.
		/// </summary>
		/// <param name="message">The message to get conditions for.</param>
		/// <returns>A list of conditions that are associated with type of message provided.</returns>
        public IList<Predicate<IMessage>> GetConditionsForMessage(IMessage message)
        {
            IList<Predicate<IMessage>> result = new List<Predicate<IMessage>>();

            lock (this.locker)
                if (this.messageTypeToConditionLookup.ContainsKey(message.GetType()))
                    foreach (Predicate<IMessage> condition in this.messageTypeToConditionLookup[message.GetType()])
                        result.Add(condition);

            return result;
        }
开发者ID:vimaire,项目名称:NServiceBus_2.0,代码行数:16,代码来源:SubscriptionsManager.cs

示例4: Dispatch

        public void Dispatch(IMessage message, params object[] parameters)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            var handler = _messageHandlerFactory.Create(message.GetType(), parameters);
            var dynamicDispatcher = GetDynamicDispatcher(message.GetType());

            dynamicDispatcher(handler, message);
        }
开发者ID:DmitryNaumov,项目名称:TestCQRS,代码行数:12,代码来源:MessageDispatcher.cs

示例5: FindEventHandlersInAssemblies

 public List<HandlerInfo> FindEventHandlersInAssemblies(IMessage message)
 {
     var result = new List<HandlerInfo>();
     var methods = FindMethodsInAssemblyFromTypes(type => ((!type.IsInterface && !type.IsAbstract) &&
                                                    (type.GetInterfaces().SingleOrDefault(
                                                        x => IsEventHandler(x, message.GetType())) != null)), "Handle", type => new[] { message.GetType() });
     foreach (var methodInfo in methods)
     {
         var declaringType = methodInfo.DeclaringType;
         var staticAttribute = declaringType.GetCustomAttributes(typeof(StaticHandlerAttribute), true).SingleOrDefault();
         result.Add(new HandlerInfo(methodInfo, staticAttribute != null));
     }
     return result;
 }
开发者ID:jbouzaglou,项目名称:PetPigeonsESB,代码行数:14,代码来源:AssemblyScanner.cs

示例6: OnMessageReceived

 // OnMessageReceived - beim messageConsumer registrierte Callback-Methode,
 // wird bei Empfang einer neuen Nachricht vom messageConsumer aufgerufen
 public void OnMessageReceived(IMessage msg)
 {
     if (msg is ITextMessage)
     {
         ITextMessage tm = msg as ITextMessage;
         //Console.WriteLine("TextMessage: ID=" + tm.GetType() + "\n" + tm.Text);
         String s = tm.Text;
         Console.WriteLine(s);
         Schnorchel schnorchel = JsonConvert.DeserializeObject<Schnorchel>(s);
         Console.WriteLine(schnorchel);
     }
     else if (msg is IMapMessage)
     {
         StringBuilder msgbuffer = new StringBuilder();
         IMapMessage mm = msg as IMapMessage;
         msgbuffer.AppendFormat("MapMessage: ID={0}\n", msg.GetType());
         foreach (string key in mm.Properties.Keys)
         {
             msgbuffer.AppendFormat("  - Property '{0}' = {1}\n", key, mm.Properties[key]);
         }
         foreach (string key in mm.Body.Keys)
         {
             msgbuffer.AppendFormat("  - Eintrag '{0}' = {1}\n", key, mm.Body[key]);
         }
         Console.WriteLine(msgbuffer.ToString());
     }
     else
     {
         Console.WriteLine("\nAnderer Message-Typ: " + msg);
     }
 }
开发者ID:TLandmann,项目名称:Bachelor-HSRM-Medieninformatik,代码行数:33,代码来源:Consumer.cs

示例7: SerDesMessage

 private static void SerDesMessage(IMessage message)
 {
     var b = CustomFormatter.Serialize(message);
     var o = CustomFormatter.Deserialize(b);
     Assert.AreEqual(o.GetType(), message.GetType());
     AreEqual(message, o);
 }
开发者ID:628426,项目名称:Strive.NET,代码行数:7,代码来源:CustomFormatterTests.cs

示例8: Remove

 public void Remove(IMessage message)
 {
    if (message is Message)
       _messages.Remove(message as Message);
    else
       throw new NotSupportedException("Cannot remove message of type '" + message.GetType() + "'");
 }
开发者ID:trevorpower,项目名称:tadmap,代码行数:7,代码来源:MessageQueue.cs

示例9: CreateDelegate

        public Delegate CreateDelegate(IMessage message, Func<IServiceBus> serviceBus)
        {
            var type = message.GetType();

            if (!delegates.ContainsKey(type))
            {
                lock (lockObject)
                {
                    if (!delegates.ContainsKey(type))
                    {
                        Type messageConvertor = typeof (Action<>).MakeGenericType(type);
                        var parameter = Expression.Parameter(type, "x");
                        delegates.Add(type,
                                      Expression.Lambda(messageConvertor,
                                                        Expression.Call(Expression.Constant(serviceBus()),
                                                                        typeof (IServiceBus).GetMethod("Publish").
                                                                            MakeGenericMethod(type),
                                                                        Expression.Constant(message, type)),
                                                        parameter).Compile());
                    }
                }
            }

            return delegates[type];
        }
开发者ID:rexwhitten,项目名称:Siege,代码行数:25,代码来源:DelegateManager.cs

示例10: PublishMessage

		public Guid PublishMessage(IMessage message)
		{
			message.Created = DateTime.Now;

			if (message.Identifier == Guid.Empty)
			{
				message.Identifier = Guid.NewGuid();
			}

			if (_channel.State != ChannelState.Open)
			{
				this.WriteDebugMessage("Publication to closed channel detected. Attempting to open channel.");

				_channel.Open();

				this.WriteDebugMessage("Channel has been opened, publication may proceed.");
			}

			var record = _publicationRegistry.PublishMessage(message);

			_channel.Send(record);

			this.WriteInfoMessage(
				string.Format(
					"Message {0} (record {1}) was successfully published via the channel {2}({3}).",
					message.GetType().Name,
					record.Identifier,
					_channel.GetType().Name,
					_channel.ChannelName));

			return record.Identifier;
		}
开发者ID:smhinsey,项目名称:Euclid,代码行数:32,代码来源:DefaultPublisher.cs

示例11: Publish

 public void Publish(IMessage message, IMessageContext sender)
 {
     var messageTpye = message.GetType();
     if (handlers.ContainsKey(messageTpye))
     {
         foreach (var handler in handlers[messageTpye])
         {
             dynamic instance = handlerFactory(handler);
             try
             {
                 if (HasResponse(message))
                 {
                     var result = instance.Handle((dynamic)(message.ToPublishedMessage(sender)));
                     sender.Respond(result);
                 }
                 else
                     instance.Handle((dynamic)(message.ToPublishedMessage(sender)));
             }
             catch (Exception ex)
             {
                 sender.ErrorFormat("{0} , {1}", ex.Message, ex.StackTrace);
             }
         }
     }
 }
开发者ID:Elders,项目名称:Skynet,代码行数:25,代码来源:SkynetPublisher.cs

示例12: EnsureReliability

        public void EnsureReliability(OutboundDisruptorEntry disruptorEntry, IMessage message, IEnumerable<MessageSubscription> concernedSubscriptions, MessageWireData messageData)
        {
            var messageOptions = _messageOptions[message.GetType().FullName];

            if (messageOptions.ReliabilityLevel != ReliabilityLevel.FireAndForget)
                foreach (var wireMessage in disruptorEntry.NetworkSenderData.WireMessages)
                {
                    int seqNum;
                    if (!_endpointToSequenceNumber.TryGetValue(wireMessage.Endpoint, out seqNum))
                    {
                        _endpointToSequenceNumber.Add(wireMessage.Endpoint, 0);
                        seqNum = 0;
                    }
                    wireMessage.MessageData.SequenceNumber = seqNum;
                    _endpointToSequenceNumber[wireMessage.Endpoint] = seqNum + 1;
                }

            if (disruptorEntry.MessageTargetHandlerData.IsAcknowledgement)
            {
                SendAcknowledgementShadowMessages(message, concernedSubscriptions, disruptorEntry, messageData);
            }
            else
            {
                if (messageOptions.ReliabilityLevel == ReliabilityLevel.Persisted)
                {
                    SendShadowMessages(concernedSubscriptions, messageData, disruptorEntry);

                }
            }
        }
开发者ID:jbouzaglou,项目名称:PetPigeonsESB,代码行数:30,代码来源:ReliabilityCoordinator.cs

示例13: Get

 /// <summary>
 /// Gets a <see cref="MessageDescription"/> instance prepared for the
 /// given message type.
 /// </summary>
 /// <param name="message">The message for which a <see cref="MessageDescription"/> should be obtained.</param>
 /// <returns>
 /// A <see cref="MessageDescription"/> instance.
 /// </returns>
 internal MessageDescription Get(IMessage message)
 {
     Contract.Requires(message != null);
     Contract.Ensures(Contract.Result<MessageDescription>() != null);
     ErrorUtilities.VerifyArgumentNotNull(message, "message");
     return this.Get(message.GetType(), message.Version);
 }
开发者ID:jcp-xx,项目名称:dotnetopenid,代码行数:15,代码来源:MessageDescriptionCollection.cs

示例14: HandleMessage

    public override bool HandleMessage(IMessage message)
    {
        if(message.GetType() == typeof(ConnectionMessage))
        {
            // pass on message to Entity handler
            base.HandleMessage(message);
        }

        if (message.GetType() == typeof(StringMessage))
        {
            StringMessage msg = message as StringMessage;
            gs.SetResponse(Responses.MESSAGE, "\"" + msg.Text + "\"");
        }

        return true;
    }
开发者ID:pandaboy,项目名称:Testground,代码行数:16,代码来源:Demo3Character.cs

示例15: Handle

 public static void Handle(object handler, IMessage message)
 {
     Type messageType = message.GetType();
     var method = handler.GetType()
         .GetMethods(BindingFlags.Instance | BindingFlags.Public)
         .Single(e => e.Name == "Handle" && e.GetParameters().Count() == 1 && e.GetParameters()[0].ParameterType == messageType);
     method.Invoke(handler, new object[] { message });
 }
开发者ID:mojamcpds,项目名称:NEventStore.Cqrs,代码行数:8,代码来源:MessageHandlerUtils.cs


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