public override void RazorFileChanged(string filePath, RazorFileChangeKind kind) { _foregroundDispatcher.AssertForegroundThread(); switch (kind) { case RazorFileChangeKind.Removed: if (_documentLookup.ContainsKey(filePath)) { // Document deleted, evict entry. _documentLookup.Remove(filePath); } break; } }
public RazorFileChangeEventArgs( string filePath, ProjectInstance projectInstance, RazorFileChangeKind kind) { if (filePath is null) { throw new ArgumentNullException(nameof(filePath)); } if (projectInstance is null) { throw new ArgumentNullException(nameof(projectInstance)); } FilePath = filePath; UnevaluatedProjectInstance = projectInstance; Kind = kind; }
// Internal for testing internal ProjectConfigurationFileChangeEventArgs( string configurationFilePath, RazorFileChangeKind kind, JsonFileDeserializer jsonFileDeserializer) { if (configurationFilePath is null) { throw new ArgumentNullException(nameof(configurationFilePath)); } if (jsonFileDeserializer is null) { throw new ArgumentNullException(nameof(jsonFileDeserializer)); } ConfigurationFilePath = configurationFilePath; Kind = kind; _jsonFileDeserializer = jsonFileDeserializer; _projectSnapshotHandleLock = new object(); }
public void RazorFileChanged(string filePath, RazorFileChangeKind kind) { if (filePath is null) { throw new ArgumentNullException(nameof(filePath)); } _projectSnapshotManagerDispatcher.AssertDispatcherThread(); switch (kind) { case RazorFileChangeKind.Added: _projectService.AddDocument(filePath); break; case RazorFileChangeKind.Removed: _projectService.RemoveDocument(filePath); break; } }
public void ProjectFileChanged(string filePath, RazorFileChangeKind kind) { if (filePath is null) { throw new ArgumentNullException(nameof(filePath)); } _foregroundDispatcher.AssertForegroundThread(); switch (kind) { case RazorFileChangeKind.Added: _projectService.AddProject(filePath); break; case RazorFileChangeKind.Removed: _projectService.RemoveProject(filePath); break; } }
private void FileSystemWatcher_ProjectConfigurationFileEvent(string physicalFilePath, RazorFileChangeKind kind) { var args = new ProjectConfigurationFileChangeEventArgs(physicalFilePath, kind); foreach (var listener in _listeners) { listener.ProjectConfigurationFileChanged(args); } }
private void FileSystemWatcher_ProjectConfigurationFileEvent_Background(string physicalFilePath, RazorFileChangeKind kind) { Task.Factory.StartNew( () => FileSystemWatcher_ProjectConfigurationFileEvent(physicalFilePath, kind), CancellationToken.None, TaskCreationOptions.None, _foregroundDispatcher.ForegroundScheduler); }
// Internal for testing internal void FileSystemWatcher_RazorFileEvent_Background(string physicalFilePath, RazorFileChangeKind kind) { lock (_pendingNotificationsLock) { if (!_pendingNotifications.TryGetValue(physicalFilePath, out var currentNotification)) { currentNotification = new DelayedFileChangeNotification(); _pendingNotifications[physicalFilePath] = currentNotification; } if (currentNotification.ChangeKind != null) { // We've already has a file change event for this file. Chances are we need to normalize the result. Debug.Assert(currentNotification.ChangeKind == RazorFileChangeKind.Added || currentNotification.ChangeKind == RazorFileChangeKind.Removed); if (currentNotification.ChangeKind != kind) { // Previous was added and current is removed OR previous was removed and current is added. Either way there's no // actual change to notify, null it out. currentNotification.ChangeKind = null; } else { Debug.Fail($"Unexpected {kind} event because our prior tracked state was the same."); } } else { currentNotification.ChangeKind = kind; } if (currentNotification.NotifyTask == null) { // The notify task is only ever null when it's the first time we're being notified about a change to the corresponding file. currentNotification.NotifyTask = NotifyAfterDelayAsync(physicalFilePath); } } }
public ProjectConfigurationFileChangeEventArgs( string configurationFilePath, RazorFileChangeKind kind) : this(configurationFilePath, kind, JsonFileDeserializer.Instance) { }
// Internal for testing internal void FileSystemWatcher_RazorDocumentOutputEvent(string filePath, ProjectInstance projectInstance, RazorFileChangeKind changeKind) { var args = new RazorFileChangeEventArgs(filePath, projectInstance, changeKind); for (var i = 0; i < _documentOutputChangeListeners.Count; i++) { _documentOutputChangeListeners[i].RazorDocumentOutputChanged(args); } }
public DocumentChangeInfo(string filePath, string relativeFilePath, RazorFileChangeKind changeKind) { FilePath = filePath; RelativeFilePath = relativeFilePath; ChangeKind = changeKind; }
public abstract void RazorFileChanged(string filePath, RazorFileChangeKind kind);
private void FileSystemWatcher_ProjectConfigurationFileEvent_Background(string physicalFilePath, RazorFileChangeKind kind) { _ = _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync( () => FileSystemWatcher_ProjectConfigurationFileEvent(physicalFilePath, kind), CancellationToken.None); }
public override void RazorFileChanged(string filePath, RazorFileChangeKind kind) { throw new NotImplementedException(); }
// Internal for testing internal void FileSystemWatcher_RazorDocumentEvent(string filePath, string projectDirectory, ProjectInstance projectInstance, RazorFileChangeKind changeKind) { var relativeFilePath = ResolveRelativeFilePath(filePath, projectDirectory); var args = new RazorFileChangeEventArgs(filePath, relativeFilePath, projectInstance, changeKind); for (var i = 0; i < _documentChangeListeners.Count; i++) { _documentChangeListeners[i].RazorDocumentChanged(args); } }