我收到以下错误消息:
无法从“ RemoteFilesWatcherService”转换为 “ IWatcherService”
它在以下行上引发:
var coll = new CollectionService(fileWatcherService);
这是我下面的代码结构。
我不明白为什么我不能仅仅将RemoteFilesWatcherService
作为CollectionService
传递到IWatcherService<IEntity>
的ctor中,因为RemoteFilesWatcherService
实现了IRemoteFilesWatcherService
,它继承自{{1} }对我来说应该可以使用。
IWatcherService<RawDataFile>
编辑:
public interface IWatcherService<TDataEntity> where TDataEntity : IEntity
{
void Watch();
INotificationFactory NotificationFactory { get; }
ObservableCollection<TDataEntity> MatchingEntries { get; set; }
}
public interface IRemoteFilesWatcherService : IWatcherService<RawDataFile>
{
IRemoteFilesRepository<IDbManager, RawDataFile> RemoteFilesRepository { get; }
}
public class RemoteFilesWatcherService : IRemoteFilesWatcherService
{
}
class CollectionService
{
private IWatcherService<IEntity> _watcherService;
public CollectionService(IWatcherService<IEntity> watcherService)
{
_watcherService = watcherService;
}
}
class Run
{
void DoIt()
{
var fileWatcherService = new RemoteFilesWatcherService();
var coll = new CollectionService(fileWatcherService);
}
}