Skip to content

Commit

Permalink
(#123) Do not add Context Type if Pipebased
Browse files Browse the repository at this point in the history
This is because the recived context will probably not be the
same type as the pipe based type.
  • Loading branch information
pardahlman committed Feb 19, 2017
1 parent 6601fbf commit 25db14d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace RawRabbit.Enrichers.MessageContext.Subscribe
{
public static class PipeContextExtensions
{
private const string PipebasedContextFunc = "PipebasedContextFunc";
public const string PipebasedContextFunc = "Subscribe:MessageContext:PipebasedContext";
private const string MessageContextType = "Subscribe:MessageContext:Type";

public static IPipeContext UseMessageContext(this IPipeContext context, Func<IPipeContext, object> contextFunc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ public static Task<IPipeContext> SubscribeAsync<TMessage, TMessageContext>(
{
Func<object[], Task> genericHandler = args => subscribeMethod((TMessage)args[0], (TMessageContext)args[1]);

context?.Invoke(ctx);
ctx.Properties.Add(PipeKey.MessageType, typeof(TMessage));
ctx.AddMessageContextType<TMessageContext>();
if (!ctx.Properties.ContainsKey(PipeContextExtensions.PipebasedContextFunc))
{
ctx.AddMessageContextType<TMessageContext>();
}
ctx.Properties.Add(PipeKey.MessageHandler, genericHandler);
context?.Invoke(ctx);
}, token);
}
}
Expand Down

0 comments on commit 25db14d

Please sign in to comment.