/// <summary>
        /// Disposes this instance.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                ProjectContextUnloaded?.Invoke(this, new ProjectContextEventArgs(this));
            }

            base.Dispose(disposing);
        }
        /// <summary>
        /// Disposes this instance.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                foreach (var provider in SubTreeProviders)
                {
                    provider.Value.DependenciesChanged -= OnDependenciesChanged;
                }

                ProjectContextUnloaded?.Invoke(this, new ProjectContextEventArgs(this));
            }

            base.Dispose(disposing);
        }
示例#3
0
        /// <summary>
        /// When a given project context is unloaded, remove it form the cache and unregister event handlers
        /// </summary>
        internal void OnProjectContextUnloaded(object sender, ProjectContextEventArgs e)
        {
            var context = e.Context;

            if (context == null)
            {
                return;
            }

            ProjectContextUnloaded?.Invoke(this, e);
            // Remove context for the unloaded project from the cache
            ProjectContexts.TryRemove(context.ProjectFilePath, out IDependenciesGraphProjectContext removedContext);

            context.ProjectContextChanged  -= OnProjectContextChanged;
            context.ProjectContextUnloaded -= OnProjectContextUnloaded;
        }
        /// <summary>
        /// Disposes this instance.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                ProjectContextUnloaded?.Invoke(this, new ProjectContextEventArgs(this));

                try
                {
                    foreach (var provider in SubTreeProviders)
                    {
                        provider.Value.DependenciesChanged -= OnDependenciesChanged;
                    }
                }
                catch (ObjectDisposedException)
                {
                    // do nothing - we are cleaning up here and sometimes CPS throws Object disposed exception
                }
            }

            base.Dispose(disposing);
        }