나는이 interface
: 다음C# 화합 제네릭 인터페이스와 추상 클래스
public abstract class MigrationSchema<T> : IMigrationSchema<T>
{
public abstract T MapEvent(IOtherEvent sourceEvent);
}
내 MigrationSchema
의 실제 구현 :
public class MigrationSchemaImpl: MigrationSchema<EventAfterMigration>
{
public MigrationSchemaImpl()
: base()
{
}
public override EventAfterMigrationMapEvent(IOtherEvent actualSourceEvent)
{
return new EventAfterMigration(actualSourceEvent);
}
}
abstract
클래스에 의해 구현
public interface IMigrationSchema<T>
{
T MapEvent(IOtherEvent sourceEvent);
}
:
public class EventAfterMigration : BaseEvent
것은 내가 이상적으로 할 싶습니다 무엇 :
var migrationSchema = container.Resolve<IMigrationSchema<BaseEvent>>();
내 config 파일에서 가진 :이 추상적 인 것 알고
<register type="IMigrationSchema`1[[MyApp.BaseEvent, MyApp]]" mapTo="MigrationSchemaImpl">
, 나는 많은을 테스트 한을 가능성은 있지만 언제든지 InvalidCastException
이 표시되면서 해당
MigrationSchemaImpl cannot be cast to IMigrationSchema1[BaseEvent]
나는 이것이 완벽하게 실현 될 수 있다고 생각하지만 나는 간단한 것을 놓치고있다. 어떤 도움을 주셔서 감사합니다!
IMigrationSchema'1 [[MyApp.BaseEvent, MyApp]]'에서 ''1 '없이 시도한 적이 있습니까? – jcharlesworthuk
그래, 작동하지 않습니다. – LaurentH