refactor(*): Refactor GetFileRepository to simplify the factory class and handle bad repository types

Thanks to the enum it shouldn't be possible for there to be a bad repository type passed as an argument to this method, but this will handle it just in case.
This commit is contained in:
Josh Creek
2021-08-29 23:40:04 +01:00
parent 7039886034
commit 85c8769631
+18 -3
View File
@@ -47,11 +47,26 @@ namespace FileRepository
/// <returns>Returns an initialised repository.</returns>
public IFileRepository GetFileRepository(RepositoryType repositoryType)
{
throw new NotImplementedException("This section won't work until another method is set up with at least one repository type.");
switch (repositoryType)
{
//case RepositoryType.Disk:
// return new DiskRepo() { };
//IFileRepository fileRepository = // Here we need to get the specific class of repository based on the RepositoryType enum.
//case RepositoryType.MongoDb:
// break;
//return fileRepository;
//case RepositoryType.S3:
// break;
//case RepositoryType.Sftp:
// break;
//case RepositoryType.Sql:
// break;
default:
throw new ArgumentException($"{Enum.GetName(typeof(RepositoryType), value: repositoryType)} is not a valid repository type.");
}
}
}
}