public void Configure(MessageChain chain) { if (!chain.HasHandler()) { return; } var handler = chain.Handler(); var handlerType = handler.HandlerType; if (!handlerType.HasAttribute<WrapWithHandlerAttribute>()) { return; } var attributes = handlerType.GetAllAttributes<WrapWithHandlerAttribute>(); foreach (var attribute in attributes) { var targetType = attribute.HandlerType; if (targetType.IsOpenGeneric()) { targetType = targetType.MakeGenericType(chain.MessageType); } else { if (targetType.FindParameterTypeTo(typeof(IHandler<>)) != chain.MessageType) { continue; } } handler.WrapWith(new WrapperNode(targetType)); } }
public void Configure(MessageChain chain) { if (chain.MessageType == typeof(SayHello) && chain.HasHandler() && chain.Handler().HandlerType == typeof(SayHelloInRussian)) { chain.Handler().WrapWith(new HandlerNode(typeof (TrapSayHelloError))); } }
public void Configure(MessageChain chain) { if (_filter.MatchesAll(chain)) { _action.Do(chain); } }
public void Configure(MessageChain chain) { if (chain.MessageType == typeof(SayHello) && chain.HasHandler() && chain.Handler().HandlerType == typeof(SayHelloInGerman)) { chain.Handler().WrapWith(new ConditionalNode(typeof (LanguageNotAllowed))); } }
public static async Task SendAsync(this Group group, MessageChain message) { _logger.LogInformation($"{_client.GetType().Name}(Group) < {group.Identifier} : {message}"); await _client.SendGroupMessageAsync(group, message); }
public static async Task SendAsync(this Friend friend, MessageChain message) { _logger.LogInformation($"{_client.GetType().Name}(Friend) < {friend.Identifier} : {message}"); await _client.SendFriendMessageAsync(friend, message); }
private IMessage ParseDelimitedMessage() { Token token = this.NextToken(); while (token != null && token.TokenType == TokenType.Terminator) { token = this.NextToken(); } if (token == null) { return(null); } this.PushToken(token); if (IsCommaOrRightParenthesis(token)) { return(null); } IMessage msg = this.ParseSimpleMessage(true, true); token = this.NextToken(); if (IsTerminator(token)) { this.PushToken(token); return(msg); } if (IsCommaOrRightParenthesis(token)) { this.PushToken(token); return(msg); } this.PushToken(token); MessageChain messages = new MessageChain(msg); messages.AddMessage(this.ParseSimpleMessage(true, false)); token = this.NextToken(); while (!IsTerminator(token)) { this.PushToken(token); if (IsCommaOrRightParenthesis(token)) { break; } messages.AddMessage(this.ParseSimpleMessage(true, false)); token = this.NextToken(); } if (IsTerminator(token)) { this.PushToken(token); } return(messages); }
public MessageChain NewChainFor(Type message) { var chain = new MessageChain(message); _chains[message].Add(chain); return chain; }