我有类库项目,大多数类是内部的,不能从外部访问。我想从这个库中注入这些类的依赖关系。我不知道我该怎么做?类库中的依赖注入如何?
示例代码:
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
}
}
你想出了一个很好的方法来解决这个问题吗?我面临同样的问题,不知道如何继续。 – frostymarvelous