구조체, 예를 들어 ITest
에 대해 struct Test
이라는 인터페이스를 확인하도록 Unity를 구성하고 싶습니다.Unity에서 구조체를 인터페이스에 바인딩 할 수 있습니까?
<unity>
<containers>
<container>
<types>
<type
type="my.ITest, asm"
mapTo="my.Test, asm">
</type>
</types>
</container>
</containers>
</unity>
을하지만 난 다음 오류 받고 있어요 : 지금까지 다음이
Resolution of the dependency failed, type = "my.ITest", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type Test cannot be constructed. You must configure the container to supply this value.
At the time of the exception, the container was:
Resolving my.Test,(none) (mapped from my.ITest,(none))
왜?
왜'Activator.CreateInstance'는 구조체를 만들 수 없습니다? – Lee
나는 이것을 시험했다; 구조체에 인터페이스가 있으면 CreateInstance 호출이 실패합니다. 이유를 알 수 없습니다. – Tejs
'Int32'는 많은 인터페이스를 구현하며 잘 작동합니다. – Lee