Why exactly isn't MEF a DI/IoC container?

后端 未结 2 646
一生所求
一生所求 2020-11-28 23:02

It\'s been said on the blogosphere and by Microsoft themselves that MEF isn\'t another IoC container.

OK...but why? It seems the same to me. Maybe it\'s not as good

2条回答
  •  半阙折子戏
    2020-11-28 23:52

    MEF has potential, but as a DI container, it lacks:

    1. Code as Configuration
    2. Auto Registration
    3. XML configuration (not so important to me)
    4. Custom Lifetimes
    5. Interception

    Those things are pretty important.

    For Lifestyle it lacks:

    1. Per graph
    2. Web Request Context
    3. Thread Context
    4. Session Context
    5. Pooled
    6. Scoped
    7. Custom Reference

    References: - Mark Seemann's book "Dependency Injection in .NET"

提交回复
热议问题