Skip to content

Commit

Permalink
Derived Model from NotifyBase
Browse files Browse the repository at this point in the history
  • Loading branch information
cuhsat committed Jun 7, 2022
1 parent 963198c commit 30a929f
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/Caliban.Nano/Data/Model.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using Caliban.Nano.Contracts;

namespace Caliban.Nano.Data
{
/// <summary>
/// A base model.
/// </summary>
public abstract partial class Model : IModel
public abstract partial class Model : NotifyBase, IModel
{
/// <inheritdoc />
public event PropertyChangedEventHandler? PropertyChanged;

/// <inheritdoc />
public bool HasChanged { get; protected set; } = false;

Expand Down Expand Up @@ -69,11 +65,11 @@ protected virtual void Set<T>(T value, [CallerMemberName] string? name = null, p
_values[name] = value;
}

PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
NotifyPropertyChanged(name);

foreach (var other in others)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(other));
NotifyPropertyChanged(other);
}
}
}
Expand Down

0 comments on commit 30a929f

Please sign in to comment.