到目前为止,我创建了以下界面:
public interface IDirectoryInfoWrapper
{
public IFileInfoWrapper[] GetFiles(string searchPattern, SearchOption searchType);
public IDirectoryInfoWrapper[] GetDirectories();
}
我一直在浏览将 DirectoryInfo 替换为IDirectoryInfoWrapper
. 一切都很顺利,直到我发现这个:
// Check that the directory is valid
DirectoryInfo directoryInfo = new DirectoryInfo( argPath );
if ( directoryInfo.Exists == false )
{
throw new ArgumentException
("Invalid IFileFinder.FindFiles Directory Path: " + argPath);
}
将构造函数放在接口中是没有意义的,那么我应该如何处理这行代码:
DirectoryInfo directoryInfo = new DirectoryInfo( argPath );