﻿using Prism.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ReNaming.ViewModels
{
    public class SimpleListItem<T>
    {
        public T Source { get; private set; }

        public Action<T> SelectedAction { get; private set; }

        public string Label { get; private set; }

        private DelegateCommand _SelectedCommand;
        public DelegateCommand SelectedCommand
        {
            get
            {
                return _SelectedCommand ??
                    (_SelectedCommand = new DelegateCommand(() => 
                    {
                        SelectedAction?.Invoke(Source);
                    }));
            }
        }

        public SimpleListItem(string label, T source, Action<T> action)
        {
            Label = label;
            Source = source;
            SelectedAction = action;
        }
    }
}
