/// <summary> /// Sets <see cref="DocumentMetadata.IsActive"/> to true and /// <see cref="DocumentMetadata.ActivatedAt"/> to the current time in UTC /// for the specified file. Sets <see cref="DocumentMetadata.IsActive"/> /// to false for all other files /// </summary> /// <param name="fullName">Full path and name of document file</param> public void Activate(string fullName) { if (fullName == _activatedDocument) { return; } var activated = false; foreach (var metadata in _activeDocumentMetadata) { metadata.IsActive = string.CompareOrdinal(metadata.FullName, fullName) == 0; if (metadata.IsActive) { _activatedDocument = metadata.FullName; var utcNow = _timeProvider.UtcNow; metadata.ActivatedAt = utcNow; activated = true; } } if (activated) { _normalizedUsageOrderService.SetUsageOrder( _activeDocumentMetadata, _userPreferences); ActiveDocumentMetadata.Refresh(); } }
public void UpdateCollection(ICollectionView view, IUserPreferences userPreferences) { var collection = (IList <DocumentMetadata>)view.SourceCollection; _normalizedUsageOrderService.SetUsageOrder( collection, userPreferences); }
/// <summary> /// Sets <see cref="DocumentMetadata.IsActive"/> to true and /// <see cref="DocumentMetadata.ActivatedAt"/> to the current time in UTC /// for the specified file. Sets <see cref="DocumentMetadata.IsActive"/> /// to false for all other files /// </summary> /// <param name="fullName">Full path and name of document file</param> public void Activate(string fullName) { var activatedDocument = _activeDocumentMetadata.FirstOrDefault(m => m.IsActive)?.FullName; if (fullName == activatedDocument) { return; } var activated = false; foreach (var metadata in _activeDocumentMetadata) { metadata.IsActive = _metadataEqualityService.Compare( metadata.FullName, fullName); if (metadata.IsActive) { var utcNow = _timeProvider.UtcNow; metadata.ActivatedAt = utcNow; activated = true; } } if (activated) { _normalizedUsageOrderService.SetUsageOrder( _activeDocumentMetadata, _userPreferences); ActiveDocumentMetadata.Refresh(); PinnedDocumentMetadata.Refresh(); } }