本文整理汇总了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 });
}
示例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;
}
示例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));
}
}
}
示例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")));
}
示例5: OnMapRequestHandler
private void OnMapRequestHandler()
{
if (ProcessingFinished)
{
return;
}
_handler = _factory.GetHandler(Context.Request);
if (_handler.GetType() == typeof(NullMessageHandler))
{
// TODO: handle error here.
CompleteProcessing();
}
}
示例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;
}