-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor storage providers and update BackupController
Refactored the storage provider interfaces and implementations: - Added a new using directive for `Octockup.Server.Extensions` in `BackupController.cs`. - Modified `GetProviders` in `BackupController.cs` to use `GetParametersKeys`. - Updated `AddDbContext` in `ServiceCollectionExtensions.cs` to use `filename`. - Added `ScpProvider` in `Program.cs`. - Changed `FtpProvider` and `ScpProvider` to implement `IStorageProvider<BaseStorageParameters>`. - Removed `Parameters` from `IStorageProvider` and added it to `IStorageProvider<TParams>`. - Added `GetParametersKeys` extension method in `StorageProviderExtensions.cs`. - Introduced `BaseStorageParameters` class to encapsulate common storage parameters.
- Loading branch information
Showing
8 changed files
with
45 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Sources/Octockup.Server/Extensions/StorageProviderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Octockup.Server.Providers.Storage; | ||
|
||
namespace Octockup.Server.Extensions | ||
{ | ||
public static class StorageProviderExtensions | ||
{ | ||
public static IEnumerable<string> GetParametersKeys(this IStorageProvider storageProvider) | ||
{ | ||
// storageProvider is IStorageProvider but actually is IStorageProvider<>, get generic type | ||
var type = storageProvider | ||
.GetType() | ||
.GetInterfaces() | ||
.First(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IStorageProvider<>)) | ||
.GetGenericArguments() | ||
.First(); | ||
return type.GetProperties().Select(p => p.Name); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
Sources/Octockup.Server/Providers/Storage/BaseStorageParameters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Octockup.Server.Providers.Storage | ||
{ | ||
public class BaseStorageParameters | ||
{ | ||
public string RemoteHost { get; set; } = string.Empty; | ||
public int RemotePort { get; set; } | ||
public string Username { get; set; } = string.Empty; | ||
public string Password { get; set; } = string.Empty; | ||
public string RemotePath { get; set; } = string.Empty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters