나는 다음과 같은 테스트 클래스가 있습니다제네릭에 인터페이스를 동적으로 배치하는 방법은 무엇입니까?
public class OutsideClass
{
private List<Type> _interfaces = null;
public void InjectInterfaces(Type[] types)
{
if(_interfaces == null)
{
_interfaces = new List<Type>();
}
foreach (var type in types)
{
if(type.IsInterface)
{
_interfaces.Add(type);
}
}
}
public void PerformSomethingWithTheInterfaces()
{
foreach (var i in _interfaces)
{
new Test<i>().PerformSomething(); // On this line the error occurs
}
}
}
internal class Test<T>
{
internal void PerformSomething()
{
}
}
이 그러나 메시지 Type or namespace name expected
날에 제공합니다. 어떻게 작동하도록이 코드를 조정할 수 있습니까?
내가 뭘하려는 건 클래스 라이브러리에 인터페이스의 무리를 통과하고 거기에 유니티을 사용하여 인터페이스를 기반으로 해결합니다. Resolve Extension 메서드를 사용합니다.
여기서 수행하려는 작업에 대해 설명해 주시겠습니까? –