using System; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows.Input; using ClassicAssist.Annotations; namespace ClassicAssist.Data.Autoloot { public class PropertyEntry : INotifyPropertyChanged, IComparable { private int _clilocIndex; private int[] _clilocs; private PropertyType _constraintType; private string _name; public int ClilocIndex { get => _clilocIndex; set => SetProperty( ref _clilocIndex, value ); } public int[] Clilocs { get => _clilocs; set => SetProperty( ref _clilocs, value ); } public PropertyType ConstraintType { get => _constraintType; set => SetProperty( ref _constraintType, value ); } public string Name { get => _name; set => SetProperty( ref _name, value ); } public int CompareTo( PropertyEntry other ) { if ( ReferenceEquals( this, other ) ) { return 0; } if ( ReferenceEquals( null, other ) ) { return 1; } int nameComparison = string.Compare( _name, other._name, StringComparison.InvariantCultureIgnoreCase ); return nameComparison; } public event PropertyChangedEventHandler PropertyChanged; public override string ToString() { return Name; } [NotifyPropertyChangedInvocator] protected virtual void OnPropertyChanged( [CallerMemberName] string propertyName = null ) { PropertyChanged?.Invoke( this, new PropertyChangedEventArgs( propertyName ) ); } // ReSharper disable once RedundantAssignment public virtual void SetProperty( ref T obj, T value, [CallerMemberName] string propertyName = "" ) { obj = value; OnPropertyChanged( propertyName ); } } }