Exemplo n.º 1
0
        private ProjectState(
            ProjectState older,
            ProjectDifference difference,
            HostProject hostProject,
            Project workspaceProject,
            ImmutableDictionary <string, DocumentState> documents,
            ImmutableDictionary <string, ImmutableArray <string> > importsToRelatedDocuments)
        {
            if (older == null)
            {
                throw new ArgumentNullException(nameof(older));
            }

            if (hostProject == null)
            {
                throw new ArgumentNullException(nameof(hostProject));
            }

            if (documents == null)
            {
                throw new ArgumentNullException(nameof(documents));
            }

            if (importsToRelatedDocuments == null)
            {
                throw new ArgumentNullException(nameof(importsToRelatedDocuments));
            }

            Services = older.Services;
            Version  = older.Version.GetNewerVersion();

            HostProject               = hostProject;
            WorkspaceProject          = workspaceProject;
            Documents                 = documents;
            ImportsToRelatedDocuments = importsToRelatedDocuments;

            _lock = new object();

            if ((difference & ClearDocumentCollectionVersionMask) == 0)
            {
                // Document collection hasn't changed
                DocumentCollectionVersion = older.DocumentCollectionVersion;
            }
            else
            {
                DocumentCollectionVersion = Version;
            }

            if ((difference & ClearComputedStateMask) == 0 && older._computedState != null)
            {
                // Optimistically cache the RazorProjectEngine.
                _computedState = new ComputedStateTracker(this, older._computedState);
            }

            if ((difference & ClearCachedTagHelpersMask) == 0 && _computedState != null)
            {
                // It's OK to keep the computed Tag Helpers.
                _computedState.TaskUnsafe = older._computedState?.TaskUnsafe;
            }
        }
Exemplo n.º 2
0
            public ComputedStateTracker(ProjectState state, ComputedStateTracker older = null)
            {
                _projectStateVersion = state.Version;
                _lock  = state._lock;
                _older = older;

                ProjectEngine = _older?.ProjectEngine;
                if (ProjectEngine == null)
                {
                    ProjectEngine = state.CreateProjectEngine();
                }
            }
Exemplo n.º 3
0
 public ComputedStateTracker(DocumentState state, ComputedStateTracker older = null)
 {
     _lock  = state._lock;
     _older = older;
 }