protected ViewModelBase(IScarletCommandBuilder commandBuilder) : base((commandBuilder?.Messenger) !) { CommandBuilder = commandBuilder ?? throw new ArgumentNullException(nameof(commandBuilder)); Dispatcher = commandBuilder.Dispatcher ?? throw new ArgumentNullException(nameof(IScarletCommandBuilder.Dispatcher)); CommandManager = commandBuilder.CommandManager ?? throw new ArgumentNullException(nameof(IScarletCommandBuilder.CommandManager)); Exit = commandBuilder.Exit ?? throw new ArgumentNullException(nameof(IScarletCommandBuilder.Exit)); WeakEventManager = commandBuilder.WeakEventManager ?? throw new ArgumentNullException(nameof(IScarletCommandBuilder.WeakEventManager)); BusyStack = new ObservableBusyStack((hasItems) => IsBusy = hasItems); }
protected PagedSourceListViewModelBase(IScarletCommandBuilder commandBuilder, SynchronizationContext synchronizationContext, Func <TViewModel, string> selector, IPagedDataProvider <TViewModel> pagedDataProvider) : base(synchronizationContext, selector) { CommandBuilder = commandBuilder ?? throw new ArgumentNullException(nameof(commandBuilder)); Dispatcher = commandBuilder.Dispatcher ?? throw new ArgumentNullException(nameof(IScarletCommandBuilder.Dispatcher)); CommandManager = commandBuilder.CommandManager ?? throw new ArgumentNullException(nameof(IScarletCommandBuilder.CommandManager)); _pagedDataProvider = pagedDataProvider ?? throw new ArgumentNullException(nameof(pagedDataProvider)); SelectedItems = new ObservableCollection <TViewModel>(); BusyStack = new ObservableBusyStack((hasItems) => IsBusy = hasItems); PageSize = 50; _loadCommand = commandBuilder .Create(Load, CanLoad) .WithSingleExecution() .WithBusyNotification(BusyStack) .WithAsyncCancellation() .Build(); _refreshCommand = commandBuilder .Create(Refresh, CanRefresh) .WithSingleExecution() .WithBusyNotification(BusyStack) .WithAsyncCancellation() .Build(); _unloadCommand = commandBuilder .Create(Unload, CanUnload) .WithSingleExecution() .WithBusyNotification(BusyStack) .WithAsyncCancellation() .Build(); NextCommand = commandBuilder .Create(Next, CanNext) .WithSingleExecution() .WithBusyNotification(BusyStack) .WithAsyncCancellation() .Build(); PreviousCommand = commandBuilder .Create(Previous, CanPrevious) .WithSingleExecution() .WithBusyNotification(BusyStack) .WithAsyncCancellation() .Build(); FirstCommand = commandBuilder .Create(First, CanFirst) .WithSingleExecution() .WithBusyNotification(BusyStack) .WithAsyncCancellation() .Build(); LastCommand = commandBuilder .Create(Last, CanLast) .WithSingleExecution() .WithBusyNotification(BusyStack) .WithAsyncCancellation() .Build(); }