Please pay attention to the following trivial program that uses MEF as an attachment framework for dependencies:
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
namespace ConsoleApplication2
{
[InheritedExport]
public interface ITest
{
void DoSomething();
}
[PartCreationPolicy(CreationPolicy.NonShared)]
public class Test : ITest
{
#region Implementation of ITest
public void DoSomething()
{
Program.BackToProgram();
}
#endregion
}
[Export]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class TestClient
{
private readonly ITest m_test;
[ImportingConstructor]
public TestClient(ITest test)
{
m_test = test;
}
public void DoSomethingFromTestClient()
{
m_test.DoSomething();
}
}
class Program
{
private static CompositionContainer m_container;
static void Main()
{
m_container = new CompositionContainer(new TypeCatalog(typeof(Test), typeof(TestClient)), true);
var testClient = m_container.GetExportedValue<TestClient>();
testClient.DoSomethingFromTestClient();
}
public static void BackToProgram()
{
}
}
}
Now let's analyze this with NDepend 6.3. Suppose I want to know all direct and indirect callers Program.BackToProgram:

However, the class TestClientconsumes the instance Testthrough the interface ITestusing Dependency Injection, so finding direct and indirect callers ITest.DoSomethinggives me the following:

So that gives me the big picture. Program.BackToProgrameventually called from Program.Main.
, , . , -, NDepend , , DI.
, DI , , , , DI .
, ? NDepend , MEF? , Program.BackToProgram, Program.Main .
, , ?
1
, NDepend, , . , , :

, . , DI. . .