Skip to content

Commit

Permalink
Use Count property to check if there are errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nkristek committed Aug 21, 2019
1 parent 701da26 commit 48714d9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Smaragd/ViewModels/ValidatingViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -51,13 +50,13 @@ public virtual void SetErrors(IEnumerable errors, [CallerMemberName] string prop

/// <inheritdoc />
[IsDirtyIgnored]
public virtual bool HasErrors => _errors.Any();
public virtual bool HasErrors => _errors.Count > 0;

/// <inheritdoc />
public virtual IEnumerable GetErrors(string propertyName)
{
if (String.IsNullOrEmpty(propertyName))
return _errors.SelectMany(kvp => kvp.Value.Cast<object>());
return _errors.SelectMany(kvp => kvp.Value);
return _errors.TryGetValue(propertyName, out var errors) ? errors : Enumerable.Empty<object>();
}

Expand Down

0 comments on commit 48714d9

Please sign in to comment.