public override void Invoke(CancellationToken cancellationToken)
        {
            var okToProceed = MessageBox.Show("Are you sure you want remove the entries from the project?\r\rNo files or folders will be deleted from disk.", Vsix.Name, MessageBoxButton.OKCancel, MessageBoxImage.Question);

            if (okToProceed != MessageBoxResult.OK)
            {
                return;
            }

            var dte = (DTE2)Package.GetGlobalService(typeof(DTE));

            string folder  = Path.GetDirectoryName(dte.ActiveDocument.FullName);
            string pattern = _span.GetText().Trim();
            var    entries = IgnoreQuickInfo.GetFiles(folder, pattern);

            foreach (var entry in entries.Select(e => Path.Combine(folder, e).Replace("/", "\\")))
            {
                try
                {
                    var item = dte.Solution?.FindProjectItem(entry);

                    if (item != null)
                    {
                        item.Remove();
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                }
            }
        }
コード例 #2
0
        private void ProcessPath(string pattern, SnapshotSpan span)
        {
            bool hasFiles = IgnoreQuickInfo.GetFiles(this._root, pattern).Any();

            this._cache[pattern] = hasFiles;

            if (!hasFiles)
            {
                this.OnClassificationChanged(span);
            }
        }
コード例 #3
0
        public override void Invoke(CancellationToken cancellationToken)
        {
            var okToProceed = MessageBox.Show("Are you sure you want to delete the matching file system entries?", Vsix.Name, MessageBoxButton.OKCancel, MessageBoxImage.Question);

            if (okToProceed != MessageBoxResult.OK)
            {
                return;
            }

            var dte = (DTE2)Package.GetGlobalService(typeof(DTE));

            string folder  = Path.GetDirectoryName(dte.ActiveDocument.FullName);
            string pattern = this._span.GetText().Trim();
            var    entries = IgnoreQuickInfo.GetFiles(folder, pattern);

            foreach (var entry in entries.Select(e => Path.Combine(folder, e).Replace("/", "\\")))
            {
                try
                {
                    var item = dte.Solution?.FindProjectItem(entry);

                    if (item != null)
                    {
                        item.Delete();
                    }
                    else
                    {
                        if (Directory.Exists(entry))
                        {
                            Directory.Delete(entry, true);
                        }
                        else if (File.Exists(entry))
                        {
                            File.Delete(entry);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                }
            }
        }