我有类库项目,大多数类都是内部的,无法从外部访问。我想从这个库中注入这些类依赖项。我不知道我该怎么做?
示例代码:
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
}
}