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


C# IMessageHandler.GetType方法代码示例

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


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

示例1: Invoke

        public override void Invoke(Type msgType, IMessage message, IMessageHandler handler)
        {
            // PERF: cache or create compiled Lambda to invoke this
            var method = handler.GetType().GetMethod("Handle", new[] { msgType });

            method.Invoke(handler, new object[] { message });
        }
开发者ID:zhoufoxcn,项目名称:Castle.RabbitMq,代码行数:7,代码来源:DefaultMessageHandlerInvoker.cs

示例2: MessageHandlerDecorator

 /// <summary>
 /// Initializes a new instance of the <see cref="QueueCreationDecorator" /> class.
 /// </summary>
 /// <param name="metrics">The metrics factory.</param>
 /// <param name="handler">The handler.</param>
 /// <param name="connectionInformation">The connection information.</param>
 public MessageHandlerDecorator(IMetrics metrics,
     IMessageHandler handler,
     IConnectionInformation connectionInformation)
 {
     var name = handler.GetType().Name;
     _runCodeTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.HandleTimer", Units.Calls);
     _handler = handler;
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:14,代码来源:IMessageHandlerDecorator.cs

示例3: RegisterMessageHandler

        public void RegisterMessageHandler(IMessageHandler handler, params string[] allowedRooms)
        {
            Type handlerType = handler.GetType();

            foreach (MethodInfo endpoint in handlerType.GetMethods(BindingFlags.Public | BindingFlags.Instance))
            {
                var messageAttributes = endpoint.GetCustomAttributes(typeof(HandleMessageAttribute), true);

                foreach (HandleMessageAttribute messageAttribute in messageAttributes)
                {
                    var route = messageAttribute.CreateRoute(handler, endpoint);

                    _routes.Add(allowedRooms == null || !allowedRooms.Any() ? route : new RoomSecurityRoute(route, allowedRooms));
                }
            }
        }
开发者ID:rjt011000,项目名称:NBot,代码行数:16,代码来源:MessageRouter.cs

示例4: GenerateQueueName

 /// <summary>
 /// Deterministically generates a queue name for a 
 /// <paramref name="messageHandler"/> based on the MD5 hash of its full
 /// type name
 /// </summary>
 /// <param name="messageHandler">The message handler</param>
 /// <returns>A unique and deterministic queue name based on the message
 /// handler type</returns>
 public static QueueName GenerateQueueName(IMessageHandler messageHandler)
 {
     // Produce a short type name that is safe (ish?) from collisions
     var typeName = messageHandler.GetType().FullName;
     var typeNameBytes = Encoding.UTF8.GetBytes(typeName);
     var typeHash = MD5.Create().ComputeHash(typeNameBytes);
     return string.Join("", typeHash.Select(b => ((ushort) b).ToString("x2")));
 }
开发者ID:tdbrian,项目名称:Platibus,代码行数:16,代码来源:HandlingRule.cs

示例5: OnMapRequestHandler

        private void OnMapRequestHandler()
        {
            if (ProcessingFinished)
            {
                return;
            }

            _handler = _factory.GetHandler(Context.Request);
            if (_handler.GetType() == typeof(NullMessageHandler))
            {
                // TODO: handle error here.
                CompleteProcessing();
            }
        }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:14,代码来源:SnmpApplication.cs

示例6: SafelyHandles

        private bool SafelyHandles(IMessageHandler handler, EventMessageBase message, string originalMessage)
        {
            var handles = false;

            try
            {
                handles = handler.CanHandle(message);
            }
            catch (Exception ex)
            {
                this.Logger.Error($"{handler.GetType().Name} threw exception in CanHandle() with message: {originalMessage}", ex);
            }

            return handles;
        }
开发者ID:vampireneo,项目名称:slack,代码行数:15,代码来源:SlackBot.cs


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