Skip to content

Commit

Permalink
Merge pull request #9 from FantasticFiasco/issue-2
Browse files Browse the repository at this point in the history
Fixes #2. Preventing throwing exception by pruning the views before unregistering a view.
  • Loading branch information
FantasticFiasco committed Jan 13, 2016
2 parents cc505b2 + ab6d13b commit 3eebd47
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/MvvmDialogs/DialogServiceViews.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using System.Windows;
using MvvmDialogs.Logging;
using MvvmDialogs.Properties;
using MvvmDialogs.Views;

namespace MvvmDialogs
Expand Down Expand Up @@ -143,8 +142,8 @@ private static void Unregister(IView view)
{
if (view == null)
throw new ArgumentNullException("view");
if (!InternalViews.Any(registeredView => ReferenceEquals(registeredView.Source, view.Source)))
throw new ArgumentException(Resources.ViewNotRegistered.CurrentFormat(view.GetType()), "view");

PruneInternalViews();

Logger.Write("Unregister view {0}".InvariantFormat(view.Id));
InternalViews.RemoveAll(registeredView => ReferenceEquals(registeredView.Source, view.Source));
Expand Down

0 comments on commit 3eebd47

Please sign in to comment.