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

后端 未结 2 632
一生所求
一生所求 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条回答
  • In my world DI is based on three dimensions, Object Composition, Lifetime Management, and Interception. This is what other full-blown DI containers, such as Unity, Castle Windsor, and Ninject facilitates. MEF only supports the one dimension, Object Composition. It is doing this quite well, but the remaining two dimensions are not supported in MEF.

    0 讨论(0)
  • 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"

    0 讨论(0)
提交回复
热议问题