나는 다음과 같은 클래스 (그들 중 일부는 PRISM 프레임 워크에 변경할 수 없습니다)이 있습니다일반 형식 변환
public abstract class NetworkEventBase<T> : CompositePresentationEvent<T> where T : NetworkEventPayload { }
public class NetworkEventPayload { }
public class TestEvent : NetworkEventBase<TestPayload> { }
public class TestPayload : NetworkEventPayload { }
// the following classes are PRISM classes:
public class CompositePresentationEvent<TPayload> : EventBase { }
public abstract class EventBase { }
지금 나는 그것의 기본 클래스 NetworkEventBase에 TestEvent의 인스턴스를 변환 할 필요를 IEventAggregator의 데코레이터 내부 aggregatedEvent의 실행시의 형태가 TestEvent 경우에도,
public class MessageBusAdapterInjectorDecorator : IEventAggregator {
...
public TEventType GetEvent<TEventType>() where TEventType : EventBase, new()
{
var aggregatedEvent = this.eventAggregator.GetEvent<TEventType>();
var networkEvent = aggregatedEvent as NetworkEventBase<NetworkEventPayload>;
if (networkEvent != null)
{
networkEvent.MessageBusAdapter = this.messageBusAdapter;
}
return aggregatedEvent;
}
}
그러나, networkEvent 항상 널 :
public interface IEventAggregator
{
TEventType GetEvent<TEventType>() where TEventType : EventBase, new();
}
지금 내 장식에이 같은 변환하려고 : 같은 IEventAggregator 보인다.
샘플을 편집하여 'networkEvent'의 출처가 명확하도록하십시오. –
NSA는 PRISM을위한 프레임 워크를 공개 했습니까? scnr – JeffRSon