0
我有一个工厂类,我觉得需要重新分解,采取下面的例子:我松散以下领域驱动设计原则,因此这FileFactory类是处理外部依赖的工厂
public class FileFactory
{
public static FileType Create(string fileName)
{
if(IsImageFile(fileName))
{
return new ImageFileType();
}
else if(IsDocumentFile(fileName))
{
return new DocumentFileType();
}
...
}
private static bool IsImageFile(string fileName)
{
string imageFileTypes[] = string[] {".jpg", ".gif", ".png"}; //How to avoid this line of code?
return imageFileTypes.Contains(fileName);
}
}
一个域对象。工厂类是否应该访问存储库/数据库以获取文件类型?
我应该如何处理这种情况下的依赖关系?