You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.3 KiB

using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace YOUserbase {
public class Group : INotifyPropertyChanged {
int id;
string name;
string details;
public int Id { get => id; set => ChangeValue(ref id, value); }
public string Name { get => name; set => ChangeValue(ref name, value); }
public string Details { get => details; set => ChangeValue(ref details, value); }
private static int index = 0;
public Group() {
Id = ++index;
}
// Change value so setter looks a bit nicer :)
private void ChangeValue<T>(ref T field, T value) {
if(!value.Equals(field)) {
field = value;
NotifyPropertyChanged();
}
}
// This method is called by the Set accessor of each property.
// The CallerMemberName attribute that is applied to the optional propertyName
// parameter causes the property name of the caller to be substituted as an argument.
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "") {
if(PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); }
}
public event PropertyChangedEventHandler PropertyChanged;
}
}