using System.ComponentModel;
using System.Runtime.CompilerServices;
using DatabaseEditor.Annotations;
using GalaSoft.MvvmLight.Messaging;

namespace DatabaseEditor.ViewModels
{
    public class ViewModelBase : INotifyPropertyChanged
    {
        private IMessenger _messengerInstance;
        public event PropertyChangedEventHandler PropertyChanged;

        protected IMessenger MessengerInstance
        {
            get
            {
                return this._messengerInstance ?? Messenger.Default;
            }
            set
            {
                this._messengerInstance = value;
            }
        }

        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
