예제 #1
0
        public UnityRefresher(IShellLocks locks, Lifetime lifetime, ISolution solution, UnityPluginProtocolController pluginProtocolController)
        {
            myLocks    = locks;
            myLifetime = lifetime;
            mySolution = solution;
            myPluginProtocolController = pluginProtocolController;

            if (solution.GetData <Solution>(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            myPluginProtocolController.Refresh.Advise(lifetime, model => { Refresh(); });
        }
예제 #2
0
        public UnityRefreshTracker(Lifetime lifetime, ISolution solution, UnityRefresher refresher, ChangeManager changeManager, UnityPluginProtocolController protocolController,
                                   ILogger logger)
        {
            if (solution.GetData <Solution>(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            var groupingEvent = solution.Locks.GroupingEvents.CreateEvent(lifetime, "UnityRefresherOnSaveEvent", TimeSpan.FromMilliseconds(500),
                                                                          Rgc.Invariant, refresher.Refresh);

            var protocolSolution = solution.GetProtocolSolution();

            protocolSolution.Editors.AfterDocumentInEditorSaved.Advise(lifetime, _ =>
            {
                if (refresher.IsRefreshing)
                {
                    return;
                }
                var isPlay = protocolController.UnityModel?.Play.HasTrueValue();
                if (isPlay == null || (bool)isPlay)
                {
                    return;
                }

                groupingEvent.FireIncoming();
            });

            changeManager.Changed2.Advise(lifetime, args =>
            {
                var changes = args.ChangeMap.GetChanges <ProjectModelChange>();
                if (changes == null)
                {
                    return;
                }

                if (refresher.IsRefreshing)
                {
                    return;
                }

                var hasChange = changes.Any(HasAnyFileChangeRec);
                if (!hasChange)
                {
                    return;
                }

                var isPlay = protocolController.UnityModel?.Play.HasTrueValue();
                if (isPlay == null || (bool)isPlay)
                {
                    return;
                }

                groupingEvent.FireIncoming();
            });
        }