nRoute and MEF doesn't like each other ...

20 views
Skip to first unread message

Gerhard Kreuzer

unread,
Feb 23, 2011, 3:48:45 AM2/23/11
to nro...@googlegroups.com
Hi,
 
just try to use MEF to compose my 'Proof of Concept' app, but it fails ...
 
I can't use the 'ImportingConstructor' attribute of MEF, because nRoute takes it over and throws exceptions. Unfortunately, my BI layers using MEF, as an on board service of .net 40, and I have to recraft everything, using nRoute composition instead, which will bring up side effects, I can't see now, or?
 
This is a little drawback. I think, frameworks should extend the capabillities but never should block the on board capabillities.
 
Any idea to solve that?
 
With best regards
 
Gerhard

Rishi Oberoi

unread,
Feb 23, 2011, 6:07:43 AM2/23/11
to nro...@googlegroups.com
Well, nRoute has two sets escape hatches:

1. Try creating a ILocatorAdapter that can resolve resources from MEF, and register it using nRoute.Components.Composition.Resource.RegisterLocatorAdapter method.

2. Create a custom IResourceResolver implementing attribute (see [ResolveResource] or [ResolveResourceBase] attributes), and use it to inject objects from MEF. And you easily mix this the resources from nRoute or elsewhere, say you create a MEFResolved attribute then:
        [ResolveConstructor]
        public FeedViewModel([MEFResolved]GoogleFeedService feedService, IShowIndicatorViewService indicatorViewService,
            IShowStatusViewService statusViewService)
        {
            // the first attribute can come from MEF
        }
Hope this helps,
Rishi
Reply all
Reply to author
Forward
0 new messages