Esempio n. 1
0
        /// <summary>
        /// Handles changes to the references items in the project and updates the project tree.
        /// </summary>
        /// <param name="e">A description of the changes made to the project.</param>
        /// <param name="handlerType">Specifies type of the event: DesignTimeBuild or Evaluation.</param>
        private void ProjectSubscriptionService_Changed(IProjectVersionedValue <
                                                            Tuple <IProjectSubscriptionUpdate,
                                                                   IProjectCatalogSnapshot,
                                                                   IProjectSharedFoldersSnapshot> > e,
                                                        RuleHandlerType handlerType)
        {
            DependenciesChange dependenciesChange;

            lock (_rootNodeSync)
            {
                dependenciesChange = ProcessDependenciesChanges(e.Value.Item1, e.Value.Item2);

                // process separatelly shared projects changes
                ProcessSharedProjectImportNodes(e.Value.Item3, dependenciesChange);

                // Apply dependencies changes to actual RootNode children collection
                // remove first nodes from actual RootNode
                dependenciesChange.RemovedNodes.ForEach(RootNode.RemoveChild);

                ProcessDuplicatedNodes(dependenciesChange);

                dependenciesChange.UpdatedNodes.ForEach((topLevelNode) =>
                {
                    var rootNodeChildren = RootNode.Children;
                    var oldNode          = rootNodeChildren.FirstOrDefault(x => x.Id.Equals(topLevelNode.Id));
                    if (oldNode != null)
                    {
                        RootNode.RemoveChild(oldNode);
                        RootNode.AddChild(topLevelNode);
                    }
                });

                RootNode.AddChildren(dependenciesChange.AddedNodes);

                OnDependenciesChanged(dependenciesChange.GetDiff(), e, handlerType);
            }
        }