-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUserInputConverter.cs
20 lines (16 loc) · 1.12 KB
/
UserInputConverter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
namespace LinesOfCodeCounter;
public static class UserInputConverter
{
public static void ConvertUserInputsToRealSettings(ref HashSet<string> acceptedFileTypes, ref HashSet<string> excludedFileTypes, RichTextBox richTextBoxAllowedFiles, RichTextBox richTextBoxExcludedFiles)
{
acceptedFileTypes = FillHashSetFromText(richTextBoxAllowedFiles);
excludedFileTypes = FillHashSetFromText(richTextBoxExcludedFiles);
}
public static void FillTextBoxesWithSettings(HashSet<string> acceptedFileTypes, HashSet<string> excludedFileTypes, RichTextBox richTextBoxAllowedFiles, RichTextBox richTextBoxExcludedFiles)
{
FillTextBoxFromHashSet(acceptedFileTypes, richTextBoxAllowedFiles);
FillTextBoxFromHashSet(excludedFileTypes, richTextBoxExcludedFiles);
}
static void FillTextBoxFromHashSet(HashSet<string> hashSet, RichTextBox textBox) => textBox.Text = string.Join(Environment.NewLine, hashSet.Where(line => !string.IsNullOrEmpty(line)));
static HashSet<string> FillHashSetFromText(RichTextBox textBox) => new HashSet<string>(textBox.Lines.Where(line => !string.IsNullOrEmpty(line)));
}