replace autofac with mef

Topics: General
Apr 7, 2011 at 4:30 PM

How do I replace Autofac with MEF? Can it be done? Has anybody done this?

Coordinator
Apr 7, 2011 at 4:48 PM

Good idea ! Maybe you can also switch to VB at the same time. What do you think about it ;)

Apr 7, 2011 at 5:12 PM

...Although, MEF is pretty extensible and you could definitely arrange it so all the injection worked identically to Autofac; meaning theoretically you wouldn't have to rewrite anything outside of the core framework.

What actual benefit this would then bring is another question entirely, the only perceivable things being one less binary to deploy and increased ".NET purity" :)

Apr 7, 2011 at 5:28 PM

@randompete
~~ anything outside of the core framework.

By the "core framework" you mean stuff that's in the src/orchard folder?

Apr 7, 2011 at 5:58 PM

Well... Orchard.Framework project which is where most of the injection stuff happens; maybe some bits of Orchard.Core; and probably some of the Test projects as well. But please note the word theoretically, by which I mean "in principle but you never know what else might break".

The thing is, why do you actually want MEF? It sounds like a lot of work to end up with basically the same system.

Apr 7, 2011 at 6:35 PM

@randompete
~~ why do you actually want MEF?

Because I don't want Autofac. :-)))

I don't want to learn another tool that I've no intention to use now or in the future. Simple. Ain't it?

Coordinator
Apr 7, 2011 at 6:42 PM

Why do you think you have to learn Autofac?

Apr 7, 2011 at 7:10 PM
mefmef wrote:

@randompete
~~ why do you actually want MEF?

Because I don't want Autofac. :-)))

I don't want to learn another tool that I've no intention to use now or in the future. Simple. Ain't it?

The funny thing is, to actually replace Autofac with MEF ... first you'd have to learn how Autofac works. And then do all the work of replacing it. So; no, it's not that simple.

Apr 8, 2011 at 11:27 PM

I've been using the Unity framework for several years, it works and it's heavy..
Autofac is light and Orchard contains functionality to automaticly resolve classes assignable from IDependency.

U don't need to learn Autofac at all, it just works..

Replacing Autofac by MEF sounds like a huge task and i wouldn't even think about doing so.