/// <summary> /// Constructor taking sync pair repository, and workspace commands. /// </summary> /// <param name="p_syncPairRepository"></param> /// <param name="wsCommands"></param> public AllSyncPairsViewModel(SyncPairRepository p_syncPairRepository, IWorkspaceCommands wsCommands) { // Store commands locally. _wsCommands = wsCommands; // Throw exception if parameter supplied is null if (p_syncPairRepository == null) { throw new ArgumentNullException("syncPairRepository"); } // Set name displayed on tab base.DisplayName = Strings.AllSyncPairsViewModel_DisplayName; // Store sync pair repository locally. _syncPairRepository = p_syncPairRepository; // Subscribe for notifications of when a new SyncPair is saved. _syncPairRepository.SyncPairAdded += OnSyncPairAddedToRepository; // Subscribe for notifications of when a SyncPair is deleted _syncPairRepository.SyncPairRemoved += OnSyncPairRemovedFromRepository; // Populate the AllSyncPairs collection with SyncPairViewModels. CreateAllSyncPairs(); // Attach relay command. EditSyncPairCommand = new SharpToolsMVVMRelayCommand(EditSyncPair); }
/// <summary> /// Constructor created from supplied args. /// </summary> /// <param name="p_syncPair"></param> /// <param name="p_syncPairRepository"></param> /// <param name="wsCommands"></param> public SyncPairViewModel(SyncPair p_syncPair, SyncPairRepository p_syncPairRepository, IWorkspaceCommands wsCommands) { // Create local commands. _wsCommands = wsCommands; // Check sync pair exists. if (p_syncPair == null) { throw new ArgumentNullException("p_syncPair"); } // Check sync repository exists. if (p_syncPairRepository == null) { throw new ArgumentNullException("p_syncPairRepository"); } // Set sync pair. _syncPair = p_syncPair; // Set sync pair repository. _syncPairRepository = p_syncPairRepository; // Set sync type if specified. if (_syncPair.SyncType == null) { _syncPairType = Strings.SyncPairViewModel_SyncPairTypeOption_NotSpecified; } else { _syncPairType = _syncPair.SyncType; } // Initialise source root retrieval. GetSrcRootCommand = new SharpToolsMVVMRelayCommand(GetSrcRoot); // Initialise destination root retrieval. GetDstRootCommand = new SharpToolsMVVMRelayCommand(GetDstRoot); // Initialise source root browser. BrowseSrcRootCommand = new SharpToolsMVVMRelayCommand(BrowseSrcRoot); // Initialise destination root browser. BrowseDstRootCommand = new SharpToolsMVVMRelayCommand(BrowseDstRoot); // Initialise delete sync pair. DeleteSyncPairCommand = new SharpToolsMVVMRelayCommand(Delete); SharpToolsMVVMMediator.Register("update", AddUpdate); // Listener for change events // LOG _log.Debug("Mediator Registered"); // ResultLog = new ObservableCollection <string>(); }