#if UNITY_5_3_OR_NEWER
#define NOESIS
using Noesis;
#else
using System.Windows;
using System.Windows.Threading;
#endif
using System.ComponentModel;
using System.Windows.Input;
using System;

namespace BindingMemoryLeak
{
    public class ViewModel : INotifyPropertyChanged
    {
        private readonly Random m_random;

        #region Property Change Implementation
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string name)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
        #endregion

        public int TrainingId { get; set; }
        public ICommand RandomizeTraining { get; }

        public ViewModel()
        {
            RandomizeTraining = new DelegateCommand(OnRandomizeTraining);
            m_random = new Random(Guid.NewGuid().GetHashCode());
        }

        private void OnRandomizeTraining(object obj)
        {
            TrainingId = m_random.Next(10);
            OnPropertyChanged(nameof(TrainingId));
        }
    }
}