【发布时间】:2013-07-20 04:11:57
【问题描述】:
我有类库项目,大多数类都是内部的,无法从外部访问。我想从这个库中注入这些类依赖项。我不知道我该怎么做?
示例代码:
internal interface IClass1
{
}
internal class Class1 : IClass1
{
}
internal class Class2
{
private readonly IClass1 _class1;
// I want to inject this interface from inside this project.
//Not from outside this project.
// Because this class may not accessible from other class.
internal Class2(IClass1 class1)
{
_class1 = class1;
}
internal Class2() :this(new Class1())
{
// I do it this way.
// But i want to do it using any IOC container
}
}
【问题讨论】:
-
你有没有想出解决这个问题的好方法?我面临同样的问题,不知道如何继续。
标签: c# .net dependency-injection ninject