We have different type of images, we store the image on disk in subfolders accordingly, and the metadata in database, including the fileTypeId. currently we have this:
public enum FileTypes
{
Document=1,
ProfileProto
...
}
and
switch (fileType)
case 1:
subdir = "documants"
case 2:
subdir = "profilephotos
default: ...error...
something like this
This violates SOLID's open/close principle
So I tried to create this instead:
public class DocumentFileType : IFileType
{
public int Id => 1;
public string Subfolder => "documents";
}
but the issue is, when we store the metadata of the images into database, we store the id of the type into a database field. 1 or 2 in this case. So when I retreive I should do something like IFileType fileType = IFileType.instnceWithId(1) But this is not possible of course.
What could I do instead of this?