예제 #1
0
        private async void ProjItemRemoved(EnvDTE.ProjectItem projectItem)
        {
            if (!IsEnabledForCurrentProject())
            {
                return;
            }

            try
            {
                var projectFolderPath   = Path.GetDirectoryName(projectItem.ContainingProject.FullName);
                var config              = GetProvisioningTemplateToolsConfiguration(projectFolderPath, false);
                var projectItemFullPath = ProjectHelpers.GetFullPath(projectItem);
                var pnpTemplateInfo     = GetParentProvisioningTemplateInformation(projectItemFullPath, projectFolderPath, config);
                var projectItemKind     = projectItem.Kind;

                if (pnpTemplateInfo != null)
                {
                    this.pendingProjectItemRequests.Enqueue(new ProjectItemRequestRemove()
                    {
                        ItemPath     = projectItemFullPath,
                        ItemKind     = projectItem.Kind,
                        TemplateInfo = pnpTemplateInfo,
                    });

                    await System.Threading.Tasks.Task.Run(() => ProcessPendingProjectItemRequestsWithDelay());

                    //ProcessPendingProjectItemRequests();
                }
            }
            catch (Exception ex)
            {
                LogService.Exception("Error in ItemRemoved", ex);
            }
        }
예제 #2
0
        private async void ProjItemRenamed(EnvDTE.ProjectItem projectItem, string oldName)
        {
            if (!IsEnabledForCurrentProject())
            {
                return;
            }

            if (projectItem.Kind != EnvDTE.Constants.vsProjectItemKindPhysicalFile)
            {
                // we handle only files
                // when folder with files is added, event is raised separately for all files as well
                return;
            }

            if (!ProjectHelpers.IncludeFile(projectItem.Name))
            {
                // do not handle .bundle or .map files the other files that are part of the bundle should be handled.
                // others may be defined in Constants.ExtensionsToIgnore
                return;
            }

            try
            {
                var projectFolderPath   = Path.GetDirectoryName(projectItem.ContainingProject.FullName);
                var config              = GetProvisioningTemplateToolsConfiguration(projectFolderPath, false);
                var projectItemFullPath = ProjectHelpers.GetFullPath(projectItem);
                var pnpTemplateInfo     = GetParentProvisioningTemplateInformation(projectItemFullPath, projectFolderPath, config);
                var projectItemKind     = projectItem.Kind;

                if (pnpTemplateInfo != null)
                {
                    this.pendingProjectItemRequests.Enqueue(new ProjectItemRequestRename()
                    {
                        ItemPath     = projectItemFullPath,
                        ItemKind     = projectItem.Kind,
                        TemplateInfo = pnpTemplateInfo,
                        OldName      = oldName
                    });

                    await System.Threading.Tasks.Task.Run(() => ProcessPendingProjectItemRequestsWithDelay());

                    //ProcessPendingProjectItemRequests();
                }
            }
            catch (Exception ex)
            {
                LogService.Exception("Error in ItemRenamed", ex);
            }
        }