Skip to content

Commit 9478f06

Browse files
Check for null string
1 parent 54ca9b4 commit 9478f06

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

Src/FinderOuter/ViewModels/MissingMnemonicViewModel.cs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public string KeyPath
144144
}
145145

146146

147-
private void Start()
147+
public void Start()
148148
{
149149
isChanged = false;
150150
Index = 0;
@@ -180,15 +180,15 @@ private void AddToList(IEnumerable<string> items)
180180
}
181181

182182
public IReactiveCommand AddAllCommand { get; }
183-
private void AddAll()
183+
public void AddAll()
184184
{
185185
AddToList(searchSpace.allWords);
186186
}
187187

188188
public IReactiveCommand AddSimilarCommand { get; }
189-
private void AddSimilar()
189+
public void AddSimilar()
190190
{
191-
ToAdd = ToAdd.Trim().ToLowerInvariant();
191+
ToAdd = ToAdd?.Trim().ToLowerInvariant();
192192
if (string.IsNullOrWhiteSpace(ToAdd))
193193
{
194194
Result.AddMessage("Word to add can not be null or empty.");
@@ -202,9 +202,9 @@ private void AddSimilar()
202202
}
203203

204204
public IReactiveCommand AddExactCommand { get; }
205-
private void AddExact()
205+
public void AddExact()
206206
{
207-
ToAdd = ToAdd.Trim().ToLowerInvariant();
207+
ToAdd = ToAdd?.Trim().ToLowerInvariant();
208208
if (!string.IsNullOrEmpty(ToAdd) && searchSpace.allWords.Contains(ToAdd))
209209
{
210210
if (!CurrentItems.Contains(ToAdd))
@@ -220,36 +220,48 @@ private void AddExact()
220220
}
221221

222222
public IReactiveCommand AddStartCommand { get; }
223-
private void AddStart()
223+
public void AddStart()
224224
{
225-
ToAdd = ToAdd.Trim().ToLowerInvariant();
225+
ToAdd = ToAdd?.Trim().ToLowerInvariant();
226226
if (!string.IsNullOrWhiteSpace(ToAdd))
227227
{
228228
AddToList(searchSpace.allWords.Where(x => x.StartsWith(ToAdd)));
229229
ToAdd = string.Empty;
230230
}
231+
else
232+
{
233+
Result.AddMessage("Word to add can not be null or empty.");
234+
}
231235
}
232236

233237
public IReactiveCommand AddEndCommand { get; }
234-
private void AddEnd()
238+
public void AddEnd()
235239
{
236-
ToAdd = ToAdd.Trim().ToLowerInvariant();
240+
ToAdd = ToAdd?.Trim().ToLowerInvariant();
237241
if (!string.IsNullOrWhiteSpace(ToAdd))
238242
{
239243
AddToList(searchSpace.allWords.Where(x => x.EndsWith(ToAdd)));
240244
ToAdd = string.Empty;
241245
}
246+
else
247+
{
248+
Result.AddMessage("Word to add can not be null or empty.");
249+
}
242250
}
243251

244252
public IReactiveCommand AddContainCommand { get; }
245-
private void AddContain()
253+
public void AddContain()
246254
{
247-
ToAdd = ToAdd.Trim().ToLowerInvariant();
255+
ToAdd = ToAdd?.Trim().ToLowerInvariant();
248256
if (!string.IsNullOrWhiteSpace(ToAdd))
249257
{
250258
AddToList(searchSpace.allWords.Where(x => x.Contains(ToAdd)));
251259
ToAdd = string.Empty;
252260
}
261+
else
262+
{
263+
Result.AddMessage("Word to add can not be null or empty.");
264+
}
253265
}
254266

255267

0 commit comments

Comments
 (0)