Re: [masstransit-discuss] Ninject Integration

61 views
Skip to first unread message

Chris Patterson

unread,
May 16, 2013, 1:35:12 PM5/16/13
to masstrans...@googlegroups.com
If you can, get the unit tests working with the automatic registration and discovery and submit a pull request.


On Wed, May 15, 2013 at 5:59 AM, Aaron Smith <aaron...@gmail.com> wrote:
The documentation says the Ninject metadata model isn't rich enough to get the types bound to an interface.

I believe using the Bind ToMethod call you can get what you need.

Change the LoadFrom to take a context instead of a kernel which will be passed in from the ToMethod call in Ninject.

Then the FindTypes can be changed to

        static IList<Type> FindTypes<T>(IContext kernel, Func<Type, bool> filter)
        {
            return context.Kernel.GetBindings(typeof(IConsumer))
                                          .Select(b => b.GetProvider(context).Type)
                                          .Where(filter)
                                          .ToList();
        }



--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/bc20037d-3c78-4487-ac74-9c0cfebc8c4d%40googlegroups.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jeramy Rutley

unread,
May 16, 2013, 2:53:45 PM5/16/13
to masstrans...@googlegroups.com
I took your idea and ran with it... 
calling "context.Kernel.GetBindings(typeof(IConsumer))" returns 0 items, but I was able to get it working (including unit tests) using reflection.  I'll attempt to create a pull request later today.


On Thursday, May 16, 2013 1:35:12 PM UTC-4, Chris Patterson wrote:
If you can, get the unit tests working with the automatic registration and discovery and submit a pull request.
On Wed, May 15, 2013 at 5:59 AM, Aaron Smith <aaron...@gmail.com> wrote:
The documentation says the Ninject metadata model isn't rich enough to get the types bound to an interface.

I believe using the Bind ToMethod call you can get what you need.

Change the LoadFrom to take a context instead of a kernel which will be passed in from the ToMethod call in Ninject.

Then the FindTypes can be changed to

        static IList<Type> FindTypes<T>(IContext kernel, Func<Type, bool> filter)
        {
            return context.Kernel.GetBindings(typeof(IConsumer))
                                          .Select(b => b.GetProvider(context).Type)
                                          .Where(filter)
                                          .ToList();
        }



--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages