public UnityRefreshTracker(Lifetime lifetime, ISolution solution, UnityRefresher refresher, UnityEditorProtocol protocolController, DocumentTransactionManager documentTransactionManager, IShellLocks locks, ILogger logger) { myLogger = logger; if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null) { return; } var groupingEvent = solution.Locks.GroupingEvents.CreateEvent(lifetime, "UnityRefresherOnSaveEvent", TimeSpan.FromMilliseconds(500), Rgc.Invariant, () => refresher.Refresh(false)); var protocolSolution = solution.GetProtocolSolution(); protocolSolution.Editors.AfterDocumentInEditorSaved.Advise(lifetime, _ => { if (protocolController.UnityModel.Value == null) { return; } myLogger.Verbose("protocolSolution.Editors.AfterDocumentInEditorSaved"); groupingEvent.FireIncoming(); }); documentTransactionManager.AfterTransactionCommit.Advise(lifetime, args => { if (protocolController.UnityModel.Value == null) { return; } if (args.Succeded && args.Changes != null && args.Changes.Any()) { locks.ExecuteWithReadLock(() => { if (documentTransactionManager.CurrentTransaction?.ParentTransaction == null) { myLogger.Verbose("documentTransactionManager.AfterTransactionCommit"); groupingEvent.FireIncoming(); } }); } }); }
private void CheckAllProjectsIfAutoInstallEnabled(PropertyChangedEventArgs <bool> args) { if (!args.GetNewOrNull()) { return; } myShellLocks.ReentrancyGuard.ExecuteOrQueueEx("UnityPluginInstaller.CheckAllProjects", () => myShellLocks.ExecuteWithReadLock(CheckAllProjects)); }