public SmartDataDefinesListViewModel(ISmartRawDataProvider smartDataProvider, ISmartDataManager smartDataManager, IParameterFactory parameterFactory,
                                             ITaskRunner taskRunner, IMessageBoxService messageBoxService, IWindowManager windowManager, Func <IHistoryManager> historyCreator, SmartDataSourceMode dataSourceMode)
        {
            this.smartDataProvider = smartDataProvider;
            this.parameterFactory  = parameterFactory;
            this.smartDataManager  = smartDataManager;
            this.dataSourceMode    = dataSourceMode;
            this.messageBoxService = messageBoxService;
            this.windowManager     = windowManager;
            switch (dataSourceMode)
            {
            case SmartDataSourceMode.SD_SOURCE_EVENTS:
                DefinesItems = new ObservableCollection <SmartGenericJsonData>(smartDataProvider.GetEvents());
                break;

            case SmartDataSourceMode.SD_SOURCE_ACTIONS:
                DefinesItems = new ObservableCollection <SmartGenericJsonData>(smartDataProvider.GetActions());
                break;

            case SmartDataSourceMode.SD_SOURCE_TARGETS:
                DefinesItems = new ObservableCollection <SmartGenericJsonData>(smartDataProvider.GetTargets());
                break;

            default:
                DefinesItems = new ObservableCollection <SmartGenericJsonData>();
                break;
            }

            OnItemSelected = new DelegateCommand <SmartGenericJsonData?>(ShowEditorWindow);
            CreateNew      = new DelegateCommand(CreateNewItem);
            DeleteItem     = new DelegateCommand(DeleteSelectedItem);
            Save           = new DelegateCommand(() =>
            {
                taskRunner.ScheduleTask("Saving modified SmartData defines", SaveDataToFile);
            }, () => IsModified);
            SelectedItemIndex = -1;
            // history setup
            History                  = historyCreator();
            historyHandler           = new SmartDataListHistoryHandler(DefinesItems);
            UndoCommand              = new DelegateCommand(History.Undo, () => History.CanUndo);
            RedoCommand              = new DelegateCommand(History.Redo, () => History.CanRedo);
            History.PropertyChanged += (sender, args) =>
            {
                UndoCommand.RaiseCanExecuteChanged();
                RedoCommand.RaiseCanExecuteChanged();
                IsModified = !History.IsSaved;
                RaisePropertyChanged(nameof(IsModified));
            };
            History.AddHandler(historyHandler);
        }
        public SmartDataProvider(ISmartRawDataProvider smartRawDataProvider,
                                 ICurrentCoreVersion coreVersion)
        {
            this.coreVersion = coreVersion;

            actions = smartRawDataProvider.GetActions().Where(IsSmartValidForCore).ToList();
            events  = smartRawDataProvider.GetEvents().Where(IsSmartValidForCore).ToList();
            targets = smartRawDataProvider.GetTargets().Where(IsSmartValidForCore).ToList();

            var actionKeys = actions.Select(g => g.Name).ToHashSet();
            var eventKeys  = events.Select(g => g.Name).ToHashSet();
            var targetKeys = targets.Select(g => g.Name).ToHashSet();

            eventsGroups = smartRawDataProvider.GetEventsGroups().Select(group =>
                                                                         new SmartGroupsJsonData()
            {
                Name    = group.Name,
                Members = group.Members.Where(name => eventKeys.Contains(name)).ToList()
            })
                           .ToList();

            actionsGroups = smartRawDataProvider.GetActionsGroups().Select(group =>
                                                                           new SmartGroupsJsonData()
            {
                Name    = group.Name,
                Members = group.Members.Where(name => actionKeys.Contains(name)).ToList()
            })
                            .ToList();

            targetsGroups = smartRawDataProvider.GetTargetsGroups().Select(group =>
                                                                           new SmartGroupsJsonData()
            {
                Name    = group.Name,
                Members = group.Members.Where(name => targetKeys.Contains(name)).ToList()
            })
                            .ToList();
        }