ファイル整理用ツールのPrism+WPFサンプル実装
Revisão | c9bc8463b68010f7a79e231fe70e883aaeccaffc (tree) |
---|---|
Hora | 2022-11-06 11:35:15 |
Autor | yoshy <yoshy.org.bitbucket@gz.j...> |
Commiter | yoshy |
[MOD] ファイルシステム操作系インタラクタのソースチェック処理を切り出し
@@ -17,19 +17,19 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
17 | 17 | { |
18 | 18 | //private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); |
19 | 19 | |
20 | - private readonly IFileSystemService fileSystem; | |
21 | 20 | private readonly IFileSystemOperationLogic operation; |
21 | + private readonly IFileSystemVerifyLogic verifier; | |
22 | 22 | private readonly IFileSystemDialogLogic dialog; |
23 | 23 | private readonly IFolderTreeService folderTree; |
24 | 24 | |
25 | 25 | public FileSystemCopyOperationInteractor( |
26 | - IFileSystemService fileSystem, | |
27 | 26 | IFileSystemOperationLogic operation, |
27 | + IFileSystemVerifyLogic verifier, | |
28 | 28 | IFileSystemDialogLogic dialog, |
29 | 29 | IFolderTreeService folderTree) |
30 | 30 | { |
31 | - this.fileSystem = fileSystem; | |
32 | 31 | this.operation = operation; |
32 | + this.verifier = verifier; | |
33 | 33 | this.dialog = dialog; |
34 | 34 | this.folderTree = folderTree; |
35 | 35 | } |
@@ -41,12 +41,12 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
41 | 41 | |
42 | 42 | string verifyMsg; |
43 | 43 | |
44 | - if (!VerifyTargetFolders(targetFolders, out verifyMsg)) | |
44 | + if (!this.verifier.VerifyCopyTargetFolders(targetFolders, out verifyMsg)) | |
45 | 45 | { |
46 | 46 | return UseCaseResponse.Abort<FileSystemCopyOperationResponse>(verifyMsg); |
47 | 47 | } |
48 | 48 | |
49 | - if (!VerifySourceFilesList(sourceFilesList, out verifyMsg)) | |
49 | + if (!this.verifier.VerifyCopySourceFilesList(sourceFilesList, out verifyMsg)) | |
50 | 50 | { |
51 | 51 | return UseCaseResponse.Abort<FileSystemCopyOperationResponse>(verifyMsg); |
52 | 52 | } |
@@ -70,62 +70,6 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
70 | 70 | return new(); |
71 | 71 | } |
72 | 72 | |
73 | - private bool VerifyTargetFolders(IEnumerable<FileSystemTargetFolder> targetFolders, out string verifyMsg) | |
74 | - { | |
75 | - IEnumerable<FileSystemTargetFolder> errorFolders = this.fileSystem.VerifyTargetFolders(targetFolders); | |
76 | - | |
77 | - verifyMsg = CreateVerifyTargetFolderErrorMessage(errorFolders); | |
78 | - | |
79 | - return !string.IsNullOrEmpty(verifyMsg); | |
80 | - } | |
81 | - | |
82 | - private static string CreateVerifyTargetFolderErrorMessage(IEnumerable<FileSystemTargetFolder> errorFolders) | |
83 | - { | |
84 | - if (errorFolders.Any()) | |
85 | - { | |
86 | - return string.Empty; | |
87 | - } | |
88 | - | |
89 | - string msg = "【仮】コピー先フォルダが見つかりません"; | |
90 | - | |
91 | - foreach (FileSystemTargetFolder errorFolder in errorFolders) | |
92 | - { | |
93 | - msg += "\nコピー先:" + errorFolder.AbsolutePath; | |
94 | - } | |
95 | - | |
96 | - return msg; | |
97 | - } | |
98 | - | |
99 | - private bool VerifySourceFilesList(IEnumerable<FileSystemSourceFiles> sourceFilesList, out string verifyMsg) | |
100 | - { | |
101 | - IEnumerable<FileSystemSourceFiles> errorFilesList = this.fileSystem.VerifySourceFilesList(sourceFilesList); | |
102 | - | |
103 | - verifyMsg = CreateVerifySourceFilesErrorMesage(errorFilesList); | |
104 | - | |
105 | - return !string.IsNullOrEmpty(verifyMsg); | |
106 | - } | |
107 | - | |
108 | - private static string CreateVerifySourceFilesErrorMesage(IEnumerable<FileSystemSourceFiles> errorFilesList) | |
109 | - { | |
110 | - if (errorFilesList.Any()) | |
111 | - { | |
112 | - return string.Empty; | |
113 | - } | |
114 | - | |
115 | - string msg = "【仮】コピー元ファイルが見つかりません"; | |
116 | - | |
117 | - foreach (FileSystemSourceFiles errorFiles in errorFilesList) | |
118 | - { | |
119 | - msg += "\nコピー元:" + errorFiles.AbsolutePath; | |
120 | - foreach (string name in errorFiles.Names) | |
121 | - { | |
122 | - msg += "\n・" + name; | |
123 | - } | |
124 | - } | |
125 | - | |
126 | - return msg; | |
127 | - } | |
128 | - | |
129 | 73 | private void SelectNode(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries) |
130 | 74 | { |
131 | 75 | FileSystemSourceFilesTargetFolder sourceTargetEntry = sourceTargetEntries.First(); |
@@ -17,19 +17,19 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
17 | 17 | { |
18 | 18 | //private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); |
19 | 19 | |
20 | - private readonly IFileSystemService fileSystem; | |
21 | 20 | private readonly IFileSystemOperationLogic operation; |
21 | + private readonly IFileSystemVerifyLogic verifier; | |
22 | 22 | private readonly IFileSystemDialogLogic dialog; |
23 | 23 | private readonly IFolderTreeService folderTree; |
24 | 24 | |
25 | 25 | public FileSystemMoveOperationInteractor( |
26 | - IFileSystemService fileSystem, | |
27 | 26 | IFileSystemOperationLogic operation, |
27 | + IFileSystemVerifyLogic verifier, | |
28 | 28 | IFileSystemDialogLogic dialog, |
29 | 29 | IFolderTreeService folderTree) |
30 | 30 | { |
31 | - this.fileSystem = fileSystem; | |
32 | 31 | this.operation = operation; |
32 | + this.verifier = verifier; | |
33 | 33 | this.dialog = dialog; |
34 | 34 | this.folderTree = folderTree; |
35 | 35 | } |
@@ -41,12 +41,12 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
41 | 41 | |
42 | 42 | string verifyMsg; |
43 | 43 | |
44 | - if (!VerifyTargetFolders(targetFolders, out verifyMsg)) | |
44 | + if (!this.verifier.VerifyMoveTargetFolders(targetFolders, out verifyMsg)) | |
45 | 45 | { |
46 | 46 | return UseCaseResponse.Abort<FileSystemMoveOperationResponse>(verifyMsg); |
47 | 47 | } |
48 | 48 | |
49 | - if (!VerifySourceFilesList(sourceFilesList, out verifyMsg)) | |
49 | + if (!this.verifier.VerifyMoveSourceFilesList(sourceFilesList, out verifyMsg)) | |
50 | 50 | { |
51 | 51 | return UseCaseResponse.Abort<FileSystemMoveOperationResponse>(verifyMsg); |
52 | 52 | } |
@@ -70,62 +70,6 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
70 | 70 | return new(); |
71 | 71 | } |
72 | 72 | |
73 | - private bool VerifyTargetFolders(IEnumerable<FileSystemTargetFolder> targetFolders, out string verifyMsg) | |
74 | - { | |
75 | - IEnumerable<FileSystemTargetFolder> errorFolders = this.fileSystem.VerifyTargetFolders(targetFolders); | |
76 | - | |
77 | - verifyMsg = CreateVerifyTargetFolderErrorMessage(errorFolders); | |
78 | - | |
79 | - return !string.IsNullOrEmpty(verifyMsg); | |
80 | - } | |
81 | - | |
82 | - private static string CreateVerifyTargetFolderErrorMessage(IEnumerable<FileSystemTargetFolder> errorFolders) | |
83 | - { | |
84 | - if (errorFolders.Any()) | |
85 | - { | |
86 | - return string.Empty; | |
87 | - } | |
88 | - | |
89 | - string msg = "【仮】移動先フォルダが見つかりません"; | |
90 | - | |
91 | - foreach (FileSystemTargetFolder errorFolder in errorFolders) | |
92 | - { | |
93 | - msg += "\n移動先:" + errorFolder.AbsolutePath; | |
94 | - } | |
95 | - | |
96 | - return msg; | |
97 | - } | |
98 | - | |
99 | - private bool VerifySourceFilesList(IEnumerable<FileSystemSourceFiles> sourceFilesList, out string verifyMsg) | |
100 | - { | |
101 | - IEnumerable<FileSystemSourceFiles> errorFilesList = this.fileSystem.VerifySourceFilesList(sourceFilesList); | |
102 | - | |
103 | - verifyMsg = CreateVerifySourceFilesErrorMesage(errorFilesList); | |
104 | - | |
105 | - return !string.IsNullOrEmpty(verifyMsg); | |
106 | - } | |
107 | - | |
108 | - private static string CreateVerifySourceFilesErrorMesage(IEnumerable<FileSystemSourceFiles> errorFilesList) | |
109 | - { | |
110 | - if (errorFilesList.Any()) | |
111 | - { | |
112 | - return string.Empty; | |
113 | - } | |
114 | - | |
115 | - string msg = "【仮】移動元ファイルが見つかりません"; | |
116 | - | |
117 | - foreach (FileSystemSourceFiles errorFiles in errorFilesList) | |
118 | - { | |
119 | - msg += "\n移動元:" + errorFiles.AbsolutePath; | |
120 | - foreach (string name in errorFiles.Names) | |
121 | - { | |
122 | - msg += "\n・" + name; | |
123 | - } | |
124 | - } | |
125 | - | |
126 | - return msg; | |
127 | - } | |
128 | - | |
129 | 73 | private void SelectNode(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries) |
130 | 74 | { |
131 | 75 | // FIX ME |
@@ -0,0 +1,130 @@ | ||
1 | +using FolderCategorizer2.Domain.Boundary.Service; | |
2 | +using FolderCategorizer2.Domain.Service.Dto; | |
3 | +using System.Collections.Generic; | |
4 | +using System.Linq; | |
5 | + | |
6 | +namespace FolderCategorizer2.UseCase.Internal | |
7 | +{ | |
8 | + internal class FileSystemVerifyLogic : IFileSystemVerifyLogic | |
9 | + { | |
10 | + private readonly IFileSystemService fileSystem; | |
11 | + | |
12 | + public FileSystemVerifyLogic(IFileSystemService fileSystem) | |
13 | + { | |
14 | + this.fileSystem = fileSystem; | |
15 | + } | |
16 | + | |
17 | + public bool VerifyCopyTargetFolders(IEnumerable<FileSystemTargetFolder> targetFolders, out string verifyMsg) | |
18 | + { | |
19 | + IEnumerable<FileSystemTargetFolder> errorFolders = this.fileSystem.VerifyTargetFolders(targetFolders); | |
20 | + | |
21 | + verifyMsg = CreateVerifyCopyTargetFolderErrorMessage(errorFolders); | |
22 | + | |
23 | + return !string.IsNullOrEmpty(verifyMsg); | |
24 | + } | |
25 | + | |
26 | + private static string CreateVerifyCopyTargetFolderErrorMessage(IEnumerable<FileSystemTargetFolder> errorFolders) | |
27 | + { | |
28 | + if (errorFolders.Any()) | |
29 | + { | |
30 | + return string.Empty; | |
31 | + } | |
32 | + | |
33 | + string msg = "【仮】コピー先フォルダが見つかりません"; | |
34 | + | |
35 | + foreach (FileSystemTargetFolder errorFolder in errorFolders) | |
36 | + { | |
37 | + msg += "\nコピー先:" + errorFolder.AbsolutePath; | |
38 | + } | |
39 | + | |
40 | + return msg; | |
41 | + } | |
42 | + | |
43 | + public bool VerifyCopySourceFilesList(IEnumerable<FileSystemSourceFiles> sourceFilesList, out string verifyMsg) | |
44 | + { | |
45 | + IEnumerable<FileSystemSourceFiles> errorFilesList = this.fileSystem.VerifySourceFilesList(sourceFilesList); | |
46 | + | |
47 | + verifyMsg = CreateVerifyCopySourceFilesErrorMesage(errorFilesList); | |
48 | + | |
49 | + return !string.IsNullOrEmpty(verifyMsg); | |
50 | + } | |
51 | + | |
52 | + private static string CreateVerifyCopySourceFilesErrorMesage(IEnumerable<FileSystemSourceFiles> errorFilesList) | |
53 | + { | |
54 | + if (errorFilesList.Any()) | |
55 | + { | |
56 | + return string.Empty; | |
57 | + } | |
58 | + | |
59 | + string msg = "【仮】コピー元ファイルが見つかりません"; | |
60 | + | |
61 | + foreach (FileSystemSourceFiles errorFiles in errorFilesList) | |
62 | + { | |
63 | + msg += "\nコピー元:" + errorFiles.AbsolutePath; | |
64 | + foreach (string name in errorFiles.Names) | |
65 | + { | |
66 | + msg += "\n・" + name; | |
67 | + } | |
68 | + } | |
69 | + | |
70 | + return msg; | |
71 | + } | |
72 | + | |
73 | + public bool VerifyMoveTargetFolders(IEnumerable<FileSystemTargetFolder> targetFolders, out string verifyMsg) | |
74 | + { | |
75 | + IEnumerable<FileSystemTargetFolder> errorFolders = this.fileSystem.VerifyTargetFolders(targetFolders); | |
76 | + | |
77 | + verifyMsg = CreateVerifyMoveTargetFolderErrorMessage(errorFolders); | |
78 | + | |
79 | + return !string.IsNullOrEmpty(verifyMsg); | |
80 | + } | |
81 | + | |
82 | + private static string CreateVerifyMoveTargetFolderErrorMessage(IEnumerable<FileSystemTargetFolder> errorFolders) | |
83 | + { | |
84 | + if (errorFolders.Any()) | |
85 | + { | |
86 | + return string.Empty; | |
87 | + } | |
88 | + | |
89 | + string msg = "【仮】移動先フォルダが見つかりません"; | |
90 | + | |
91 | + foreach (FileSystemTargetFolder errorFolder in errorFolders) | |
92 | + { | |
93 | + msg += "\n移動先:" + errorFolder.AbsolutePath; | |
94 | + } | |
95 | + | |
96 | + return msg; | |
97 | + } | |
98 | + | |
99 | + public bool VerifyMoveSourceFilesList(IEnumerable<FileSystemSourceFiles> sourceFilesList, out string verifyMsg) | |
100 | + { | |
101 | + IEnumerable<FileSystemSourceFiles> errorFilesList = this.fileSystem.VerifySourceFilesList(sourceFilesList); | |
102 | + | |
103 | + verifyMsg = CreateVerifyMoveSourceFilesErrorMesage(errorFilesList); | |
104 | + | |
105 | + return !string.IsNullOrEmpty(verifyMsg); | |
106 | + } | |
107 | + | |
108 | + private static string CreateVerifyMoveSourceFilesErrorMesage(IEnumerable<FileSystemSourceFiles> errorFilesList) | |
109 | + { | |
110 | + if (errorFilesList.Any()) | |
111 | + { | |
112 | + return string.Empty; | |
113 | + } | |
114 | + | |
115 | + string msg = "【仮】移動元ファイルが見つかりません"; | |
116 | + | |
117 | + foreach (FileSystemSourceFiles errorFiles in errorFilesList) | |
118 | + { | |
119 | + msg += "\n移動元:" + errorFiles.AbsolutePath; | |
120 | + foreach (string name in errorFiles.Names) | |
121 | + { | |
122 | + msg += "\n・" + name; | |
123 | + } | |
124 | + } | |
125 | + | |
126 | + return msg; | |
127 | + } | |
128 | + | |
129 | + } | |
130 | +} |
@@ -0,0 +1,13 @@ | ||
1 | +using FolderCategorizer2.Domain.Service.Dto; | |
2 | +using System.Collections.Generic; | |
3 | + | |
4 | +namespace FolderCategorizer2.UseCase.Internal | |
5 | +{ | |
6 | + internal interface IFileSystemVerifyLogic | |
7 | + { | |
8 | + bool VerifyCopySourceFilesList(IEnumerable<FileSystemSourceFiles> sourceFilesList, out string verifyMsg); | |
9 | + bool VerifyCopyTargetFolders(IEnumerable<FileSystemTargetFolder> targetFolders, out string verifyMsg); | |
10 | + bool VerifyMoveSourceFilesList(IEnumerable<FileSystemSourceFiles> sourceFilesList, out string verifyMsg); | |
11 | + bool VerifyMoveTargetFolders(IEnumerable<FileSystemTargetFolder> targetFolders, out string verifyMsg); | |
12 | + } | |
13 | +} | |
\ No newline at end of file |
@@ -67,6 +67,7 @@ namespace FolderCategorizer2.UseCase | ||
67 | 67 | |
68 | 68 | containerRegistry.Register<IFileSystemOperationLogic, FileSystemOperationLogic>(); |
69 | 69 | containerRegistry.Register<IFileSystemDialogLogic, FileSystemDialogLogic>(); |
70 | + containerRegistry.Register<IFileSystemVerifyLogic, FileSystemVerifyLogic>(); | |
70 | 71 | |
71 | 72 | logger.Trace("RegisterTypes end"); |
72 | 73 | } |