Exemple #1
0
        public void CollectActiveProjectItem()
        {
            try
            {
                DTE      dte            = (DTE)VsServiceProvider.GetService(typeof(DTE));
                Document activeDocument = dte.ActiveDocument;

                if (activeDocument == null)
                {
                    return;
                }

                IItem item        = null;
                var   projectName = activeDocument.ProjectItem.ContainingProject.FullName;

                if (SolutionInfo.IsOpenFolderModeActive())
                {
                    item = new CurrentDocument(activeDocument);
                    Items.Add(item);
                }
                else if (string.IsNullOrWhiteSpace(projectName) == false)
                {
                    item = new CurrentProjectItem(activeDocument.ProjectItem);
                    Items.Add(item);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Exemple #2
0
        // TODO : Refactor this method. Generics can be a solution.
        public void CollectActiveProjectItem()
        {
            try
            {
                DTE      dte            = (DTE)VsServiceProvider.GetService(typeof(DTE));
                Document activeDocument = dte.ActiveDocument;

                if (activeDocument == null)
                {
                    return;
                }

                IItem item = null;
                if (SolutionInfo.IsOpenFolderModeActive())
                {
                    item = new CurrentDocument(activeDocument);
                }
                else
                {
                    item = new CurrentProjectItem(activeDocument.ProjectItem);
                }

                Items.Add(item);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
        public void SetItem(Document document)
        {
            if (document == null)
            {
                return;
            }

            var projectName = document.ProjectItem.ContainingProject.FullName;

            if (string.IsNullOrWhiteSpace(projectName))
            {
                return;
            }

            IItem item = new CurrentProjectItem(document.ProjectItem);

            Items.Add(item);
        }
        public void CollectActiveProjectItem()
        {
            try
            {
                DTE      vsServiceProvider = VsServiceProvider.TryGetService(typeof(DTE), out object dte) ? (dte as DTE) : null;
                Document activeDocument    = vsServiceProvider.ActiveDocument;

                if (activeDocument != null)
                {
                    CurrentProjectItem activeProjectItem = new CurrentProjectItem(activeDocument.ProjectItem);
                    items.Add(activeProjectItem);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }