コード例 #1
0
 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));
     }
 }
コード例 #2
0
 public void Configure(MessageChain chain)
 {
     if (chain.MessageType == typeof(SayHello) && chain.HasHandler() && chain.Handler().HandlerType == typeof(SayHelloInRussian))
     {
         chain.Handler().WrapWith(new HandlerNode(typeof (TrapSayHelloError)));
     }
 }
コード例 #3
0
 public void Configure(MessageChain chain)
 {
     if (_filter.MatchesAll(chain))
     {
         _action.Do(chain);
     }
 }
コード例 #4
0
 public void Configure(MessageChain chain)
 {
     if (chain.MessageType == typeof(SayHello) && chain.HasHandler() && chain.Handler().HandlerType == typeof(SayHelloInGerman))
     {
         chain.Handler().WrapWith(new ConditionalNode(typeof (LanguageNotAllowed)));
     }
 }
コード例 #5
0
 public static async Task SendAsync(this Group group, MessageChain message)
 {
     _logger.LogInformation($"{_client.GetType().Name}(Group) < {group.Identifier} : {message}");
     await _client.SendGroupMessageAsync(group, message);
 }
コード例 #6
0
 public static async Task SendAsync(this Friend friend, MessageChain message)
 {
     _logger.LogInformation($"{_client.GetType().Name}(Friend) < {friend.Identifier} : {message}");
     await _client.SendFriendMessageAsync(friend, message);
 }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: MessageGraph.cs プロジェクト: zeitgarden/Pipes
 public MessageChain NewChainFor(Type message)
 {
     var chain = new MessageChain(message);
     _chains[message].Add(chain);
     return chain;
 }