BB84.Notifications 3.6.531

dotnet add package BB84.Notifications --version 3.6.531
                    
NuGet\Install-Package BB84.Notifications -Version 3.6.531
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BB84.Notifications" Version="3.6.531" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BB84.Notifications" Version="3.6.531" />
                    
Directory.Packages.props
<PackageReference Include="BB84.Notifications" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BB84.Notifications --version 3.6.531
                    
#r "nuget: BB84.Notifications, 3.6.531"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BB84.Notifications@3.6.531
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BB84.Notifications&version=3.6.531
                    
Install as a Cake Addin
#tool nuget:?package=BB84.Notifications&version=3.6.531
                    
Install as a Cake Tool

CI CD CodeQL Dependabot

C# Issues Commit License RepoSize Release

BB84.Notifications

net20 net21 net462 net481 net80 net90 NuGet

This repository contains relevant abstractions and implementations for one- and two-way binding of properties, for notifications about changed properties, for notifications about changed collections and for the Relay Command Pattern for synchronous and asynchronous operations.

Usage

Depending on the application, there are several ways to skin a cat.

The notifiable property class and interface

Designed with one or two way binding in mind.

public INotifiableProperty<int> NotifiableInt { get; set; } = new NotifiableProperty<int>(default);

If the property is changed, the PropertyChangingEventHandler is triggered before the value changes and the PropertyChangedEventHandler is triggered after the value has changed.

  • The PropertyChangingEventHandler contains via the PropertyChangingEventArgs the name of the property that is changing and when casted to PropertyChangingEventArgs<T> the old value of the property.
  • The PropertyChangedEventHandler contains via the PropertyChangedEventArgs the name of the property that has changed and when casted to PropertyChangedEventArgs<T> the new value of the property.

Further implementation possibilities can be achieved with the help of the INotifiableProperty<T> interface.

The reversible property class and interface

Designed with one or two way binding in mind and for switching back and forth. By default, only 10 values are saved, but a different value can be specified when initializing the property.

int defaultValue = 42;
int valuesToStore = 20;
public IReversibleProperty<int> ReversibleInt { get; set; } = new ReversibleProperty<int>(defaultValue, valuesToStore);

The reversible property contains all the functions of the notifiable property and also provides the option of switching back and forth between the values already set.

To get the previous value:

ReversibleInt.PreviousValue();

To get the next value:

ReversibleInt.NextValue();

Further implementation possibilities can be achieved with the help of the IReversibleProperty<T> interface.

The notifiable object base class and interface

Designed to handle changes at the class level and propagate them.

public sealed class TestClass : NotifiableObject
{
    private int _property;

    public int Property
    {
        get => _property;
        set => SetProperty(ref _property, value);
    }
}

If the property is changed, the PropertyChangingEventHandler is triggered before the value changes and the PropertyChangedEventHandler is triggered after the value has changed.

  • The PropertyChangingEventHandler contains via the PropertyChangingEventArgs the name of the property that is changing and when casted to PropertyChangingEventArgs<T> the old value of the property.
  • The PropertyChangedEventHandler contains via the PropertyChangedEventArgs the name of the property that has changed and when casted to PropertyChangedEventArgs<T> the new value of the property.

Further implementation possibilities can be achieved with the help of the INotifiableObject interface.

The notifiable collection base class and interface

The NotifiableCollection class provides methods to handle the change within a collection and propagate it to the outside.

public sealed class MyStringCollection : NotifiableCollection, ICollection<string>
{
  private readonly Collection<string> _collection;

  public MyStringCollection()
    => _collection = new Collection<string>();

  ..
}

Most of the implementation must be done despite the base class itself. The intention has been to be able to signal the state of a collection before (CollectionChangingEventHandler) or after (CollectionChangedEventHandler) the addition, deletion or modification of objects.

  • The CollectionChangingEventHandler contains via the CollectionChangingEventArgs the CollectionChangeAction and when casted to CollectionChangingEventArgs<T> the old value of the object.
  • The CollectionChangedEventHandler contains via the CollectionChangedEventArgs the CollectionChangeAction and when casted to CollectionChangedEventArgs<T> the new value of the object.

Further implementation possibilities can be achieved with the INotifiableCollection interface or the INotifyCollectionChanged and INotifyCollectionChanging interfaces.

The notification attributes

The NotifyChangedAttribute and the NotifyChangingAttribute propagating the information also to those properties the are defined via the constructor. An example implementation could look like this:

private sealed class TestClass : NotifyPropertyBase
{
  private int _quantity;
  private int _value;

  public TestClass(int quantity, int value)
  {
    Quantity = quantity;
    Value = value;
  }

  [NotifyChanged(nameof(TotalValue))]
  public int Quantity { get => _quantity; set => SetProperty(ref _quantity, value); }

  [NotifyChanged(nameof(TotalValue))]
  public int Value { get => _value; set => SetProperty(ref _value, value); }

  public int TotalValue => Quantity * Value;
}

If the Quantity property or the Value property is changed, a PropertyChanged event is also triggered for the TotalValue property.

To keep the costs of reflection as low as possible, the property and its properties to be notified are persisted when initializing the class that uses the attributes.

API Documentation

The complete API documentation can be found here.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.6.531 291 5/31/2025
3.6.409 630 4/9/2025
3.6.322 286 3/22/2025
3.6.319 201 3/19/2025
3.6.130 529 1/30/2025
3.5.1216 736 12/16/2024
3.5.916 1,096 9/16/2024
3.4.715 822 7/15/2024
3.4.713 137 7/13/2024
3.3.616 335 6/16/2024
3.3.606 193 6/6/2024
3.2.603 150 6/3/2024
3.2.520 328 5/20/2024
3.2.421 272 4/21/2024
3.1.421 144 4/21/2024
3.1.415 211 4/15/2024
3.0.0 307 3/25/2024
2.1.1 343 2/6/2024
2.1.0 380 1/14/2024
2.0.0 206 1/9/2024
1.8.2 266 1/1/2024
1.8.1 239 11/20/2023
1.8.0 153 11/13/2023
1.7.0 136 11/12/2023
1.6.1 134 11/12/2023
1.6.0 136 11/12/2023
1.5.0 164 11/6/2023
1.4.0 145 11/3/2023
1.3.1 154 11/1/2023
1.3.0 151 11/1/2023
1.2.1 172 10/25/2023
1.2.0 154 10/23/2023
1.1.0 160 10/21/2023
1.0.1 161 10/21/2023
1.0.0 158 10/21/2023