【发布时间】:2016-12-05 09:03:18
【问题描述】:
我有多重继承,看看下面的示例评论,以更好地了解我想要做什么。
CompanyEventsView : BaseViewModelFor<CompanyEvents>
{
}
BaseViewModelFor<TSource> : BaseViewModel where TSource : class
{
public BaseViewModelFor(IAggregator aggregator, IRepository<TSource> repository, int i)
{
Aggregator = aggregator;
var source = repository.GetKey(i);
(this as CompanyEventsView).MapFromSourceObject(source); // (this as CompanyEventsView) how could I make this generic so if I inherit another class to point to it
}
}
所以我想知道的是如何强制 (this as CompanyEventsView) 位使其始终指向从 BaseViewModelFor<> 继承的类?
【问题讨论】:
标签: c# inheritance base-class