-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Parse the arguments to the search service
- Loading branch information
1 parent
feebaa9
commit 6cae271
Showing
2 changed files
with
86 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using DicomGrepCore.Entities; | ||
using DicomGrepCore.Enums; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.CommandLine; | ||
using System.CommandLine.Binding; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DicomGrepCli | ||
{ | ||
internal class SearchCriteriaBinder : BinderBase<SearchCriteria> | ||
{ | ||
|
||
private readonly Option<string> _folderOption; | ||
private readonly Option<string> _fileTypeOption; | ||
private readonly Option<bool> _recursiveOption; | ||
private readonly Option<string> _sopClassOption; | ||
private readonly Option<string> _tagOption; | ||
private readonly Option<string> _valueOption; | ||
private readonly Option<bool> _caseSensitiveOption; | ||
private readonly Option<bool> _wholeWordOption; | ||
private readonly Option<int> _threadsOption; | ||
private readonly Option<MatchPatternEnum> _patternOption; | ||
|
||
|
||
public SearchCriteriaBinder(Option<string> folderOption, Option<string> fileTypeOption, | ||
Option<bool> recursiveOption, Option<string> sopClassOption, Option<string> tagOption, | ||
Option<string> valueOption, Option<bool> caseSensitiveOption, Option<bool> wholeWordOption, | ||
Option<int> threadsOption, Option<MatchPatternEnum> patternOption) | ||
{ | ||
_folderOption = folderOption; | ||
_fileTypeOption = fileTypeOption; | ||
_recursiveOption = recursiveOption; | ||
_sopClassOption = sopClassOption; | ||
_tagOption = tagOption; | ||
_valueOption = valueOption; | ||
_caseSensitiveOption = caseSensitiveOption; | ||
_wholeWordOption = wholeWordOption; | ||
_threadsOption = threadsOption; | ||
_patternOption = patternOption; | ||
} | ||
|
||
protected override SearchCriteria GetBoundValue(BindingContext bindingContext) | ||
{ | ||
return new SearchCriteria | ||
{ | ||
SearchPath = bindingContext.ParseResult.GetValueForOption(_folderOption), | ||
FileTypes = bindingContext.ParseResult.GetValueForOption(_fileTypeOption), | ||
IncludeSubfolders = bindingContext.ParseResult.GetValueForOption(_recursiveOption), | ||
SearchSopClassUid = bindingContext.ParseResult.GetValueForOption(_sopClassOption), | ||
SearchTag = bindingContext.ParseResult.GetValueForOption(_tagOption), | ||
SearchText = bindingContext.ParseResult.GetValueForOption(_valueOption), | ||
CaseSensitive = bindingContext.ParseResult.GetValueForOption(_caseSensitiveOption), | ||
WholeWord = bindingContext.ParseResult.GetValueForOption(_wholeWordOption), | ||
SearchThreads = bindingContext.ParseResult.GetValueForOption(_threadsOption), | ||
MatchPattern = bindingContext.ParseResult.GetValueForOption(_patternOption) | ||
}; | ||
} | ||
} | ||
} |