Skip to content

Commit

Permalink
Merge pull request #12 from ShawnLaMountain/main
Browse files Browse the repository at this point in the history
Added BindableObject
  • Loading branch information
ShawnLaMountain authored Oct 28, 2022
2 parents 7420dd2 + efed0a5 commit 694713a
Showing 3 changed files with 38 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -32,6 +32,9 @@ A simple C# repository containing a few basic useful Thread-Safe Objects.
- ObjectExtention
- HelperClasses
- ThreadHelper
- Objects
- BindableObject
- ThreadObject

----

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using ThunderDesign.Net.Threading.Extentions;
using ThunderDesign.Net.Threading.Interfaces;

@@ -10,15 +11,19 @@ public class BindableDataObject<Key> : DataObject<Key>, IBindableDataObject<Key>
public event PropertyChangedEventHandler PropertyChanged;
#endregion

#region properties
protected virtual bool WaitWhenNotifying => false;
#endregion

#region methods
protected override void SetId(Key value)
{
this.SetProperty(ref _Id, value, _Locker, true, nameof(Id));
}

public virtual void OnPropertyChanged(string propertyName)
public virtual void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
this.NotifyPropertyChanged(PropertyChanged, propertyName);
this.NotifyPropertyChanged(PropertyChanged, propertyName, WaitWhenNotifying);
}
#endregion
}
28 changes: 28 additions & 0 deletions src/ThunderDesign.Net-PCL.Threading/Objects/BindableObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text;
using ThunderDesign.Net.Threading.Extentions;
using ThunderDesign.Net.Threading.Interfaces;

namespace ThunderDesign.Net.Threading.Objects
{
public class BindableObject : ThreadObject, IBindableObject
{
#region event handlers
public event PropertyChangedEventHandler PropertyChanged;
#endregion

#region properties
protected virtual bool WaitWhenNotifying => false;
#endregion

#region methods
public virtual void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
this.NotifyPropertyChanged(PropertyChanged, propertyName, WaitWhenNotifying);
}
#endregion
}
}

0 comments on commit 694713a

Please sign in to comment.