Have you ever come across a scenario where you require to have start and end dates, validate whether these dates define valid duration, or determine overlapping duration/timespan in two given duration(s)?
If yes, here I present to you a beautiful MVVM ready, equitable, duration class which does all the above and a little more. 🙂
We will call this class TimeDuration.
TimeDuration implements two interfaces, IEquatable and INotifyPropertyChanged. In later parts we will see the implementation of methods for IEquatable, let’s have INotifyPropertyChanged implementation first. Include System.ComponentModel to your cs file and define a PropertyChangedEventHandler type public event PropertyChanged. Also create a private method onPropertyChanged with a return type void. The complete INotifyPropertyChanged implementation looks like this:
Basic information encapsulation this class represent consists of start time and end time. So we will have two public DateTime type properties; Start and End in this class. We wish to notify our…
View original post 298 more words