当前位置: 首页>>代码示例>>C#>>正文


C# IVsHierarchy类代码示例

本文整理汇总了C#中IVsHierarchy的典型用法代码示例。如果您正苦于以下问题:C# IVsHierarchy类的具体用法?C# IVsHierarchy怎么用?C# IVsHierarchy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IVsHierarchy类属于命名空间,在下文中一共展示了IVsHierarchy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EFModelErrorTask

 internal EFModelErrorTask(
     string document, string errorMessage, int lineNumber, int columnNumber, TaskErrorCategory category, IVsHierarchy hierarchy,
     uint itemID)
     : base(document, errorMessage, lineNumber, columnNumber, category, hierarchy, itemID)
 {
     Navigate += EFModelErrorTaskNavigator.NavigateTo;
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:EFModelErrorTask.cs

示例2: GetLoadedControllableProjects

        public static async Task<List<IVsSccProject2>> GetLoadedControllableProjects()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
            var list = new List<IVsSccProject2>();

            IVsSolution sol = await GetActiveSolution();
            list.Add(sol as IVsSccProject2);

            Guid rguidEnumOnlyThisType = new Guid();
            IEnumHierarchies ppenum = null;
            ErrorHandler.ThrowOnFailure(sol.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref rguidEnumOnlyThisType, out ppenum));

            IVsHierarchy[] rgelt = new IVsHierarchy[1];
            uint pceltFetched = 0;
            while (ppenum.Next(1, rgelt, out pceltFetched) == VSConstants.S_OK &&
                   pceltFetched == 1)
            {
                IVsSccProject2 sccProject2 = rgelt[0] as IVsSccProject2;
                if (sccProject2 != null && await IsProjectInGitRepoitory(sccProject2))
                {
                    list.Add(sccProject2);
                }
            }

            return list;
        }
开发者ID:annastazi09,项目名称:Git-Source-Control-Provider,代码行数:26,代码来源:SolutionExtensions.cs

示例3: GetProject

 public static Project GetProject(IVsHierarchy hierarchy)
 {
     object project;
     ErrorHandler.ThrowOnFailure(
         hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out project));
     return (Project)project;
 }
开发者ID:saint1729,项目名称:caide,代码行数:7,代码来源:SolutionUtilities.cs

示例4: OnAfterOpenProject

 public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
 {
     uint cookie;
     pHierarchy.AdviseHierarchyEvents(new ProjectEventSink(pHierarchy), out cookie);
     projectCookies[pHierarchy] = cookie;
     return 0;
 }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:7,代码来源:ProjectEventManager.cs

示例5: GetPropertyValue

        public static object GetPropertyValue(int propid, uint itemId, IVsHierarchy vsHierarchy)
        {
            if (itemId == VSConstants.VSITEMID_NIL)
            {
                return null;
            }

            try
            {
                object o;
                ErrorHandler.ThrowOnFailure(vsHierarchy.GetProperty(itemId, propid, out o));

                return o;
            }
            catch (System.NotImplementedException)
            {
                return null;
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                return null;
            }
            catch (System.ArgumentException)
            {
                return null;
            }
        }
开发者ID:midwinterfs,项目名称:TSTestExtension,代码行数:27,代码来源:VsSolutionHelper.cs

示例6: IsSingleProjectItemSelection

        private static bool IsSingleProjectItemSelection(this OleMenuCommand command, out IVsHierarchy hierarchy, out uint itemid)
        {
            hierarchy = null;
            itemid = VSConstants.VSITEMID_NIL;
            int hr = VSConstants.S_OK;

            var monitorSelection = Package.GetGlobalService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;
            var solution = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
            if (monitorSelection == null || solution == null)
            {
                return false;
            }

            IVsMultiItemSelect multiItemSelect = null;
            IntPtr hierarchyPtr = IntPtr.Zero;
            IntPtr selectionContainerPtr = IntPtr.Zero;

            try
            {
                hr = monitorSelection.GetCurrentSelection(out hierarchyPtr, out itemid, out multiItemSelect, out selectionContainerPtr);

                if (ErrorHandler.Failed(hr) || hierarchyPtr == IntPtr.Zero || itemid == VSConstants.VSITEMID_NIL)
                {
                    // there is no selection
                    return false;
                }

                // multiple items are selected
                if (multiItemSelect != null) return false;

                // there is a hierarchy root node selected, thus it is not a single item inside a project

                if (itemid == VSConstants.VSITEMID_ROOT) return false;

                hierarchy = Marshal.GetObjectForIUnknown(hierarchyPtr) as IVsHierarchy;
                if (hierarchy == null) return false;

                Guid guidProjectID = Guid.Empty;

                if (ErrorHandler.Failed(solution.GetGuidOfProject(hierarchy, out guidProjectID)))
                {
                    return false; // hierarchy is not a project inside the Solution if it does not have a ProjectID Guid
                }

                // if we got this far then there is a single project item selected
                return true;
            }
            finally
            {
                if (selectionContainerPtr != IntPtr.Zero)
                {
                    Marshal.Release(selectionContainerPtr);
                }

                if (hierarchyPtr != IntPtr.Zero)
                {
                    Marshal.Release(hierarchyPtr);
                }
            }
        }
开发者ID:patryksuchowierski,项目名称:my1stgithubrepo,代码行数:60,代码来源:ExtensionMethods.cs

示例7:

        int IVsUpdateSolutionEvents2.UpdateProjectCfg_Begin(
            IVsHierarchy pHierProj, IVsCfg pCfgProj, IVsCfg pCfgSln, uint dwAction, ref int pfCancel)
        {
            //
            //   if clean project or solution,   dwAction == 0x100000
            //   if build project or solution,   dwAction == 0x010000
            //   if rebuild project or solution, dwAction == 0x410000
            //
            if (dwAction == 0x010000
                || dwAction == 0x410000)
            {
                var validationSuccessful =
                    VisualStudioEdmxValidator.LoadAndValidateAllFilesInProject(
                        pHierProj, /*doEscherValidation*/ false, ShouldValidateArtifactDuringBuild);

                // we cause a 'build break' for command-line builds by setting PfCancel = 1
                if (PackageManager.Package.IsBuildingFromCommandLine
                    && !validationSuccessful)
                {
                    pfCancel = 1;
                }
            }

            return VSConstants.S_OK;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:25,代码来源:EdmUpdateSolutionEvents.cs

示例8: OnQueryUnloadProject

 int IVsSolutionEvents.OnQueryUnloadProject(IVsHierarchy pRealHierarchy, ref int pfCancel)
 {
     var project = VsxHelper.GetProject(pRealHierarchy);
     if (project != null)
         OnQueryUnloadProject(project);
     return VSConstants.S_OK;
 }
开发者ID:Galad,项目名称:SpecFlow,代码行数:7,代码来源:SolutionEventsListener.cs

示例9: CreateEditorInstance

 public int CreateEditorInstance(
     uint grfCreateDoc,
     string pszMkDocument,
     string pszPhysicalView,
     IVsHierarchy pvHier,
     uint itemid,
     IntPtr punkDocDataExisting,
     out IntPtr ppunkDocView,
     out IntPtr ppunkDocData,
     out string pbstrEditorCaption,
     out Guid pguidCmdUI,
     out int pgrfCdw)
 {
     ppunkDocView = IntPtr.Zero;
     ppunkDocData = IntPtr.Zero;
     pguidCmdUI = GetType().GUID;
     pgrfCdw = 0;
     pbstrEditorCaption = null;
     if ((grfCreateDoc & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0)
         return VSConstants.E_INVALIDARG;
     if (punkDocDataExisting != IntPtr.Zero)
         return VSConstants.VS_E_INCOMPATIBLEDOCDATA;
     EditorPane newEditor = new EditorPane(_vsPackage);
     ppunkDocView = Marshal.GetIUnknownForObject(newEditor);
     ppunkDocData = Marshal.GetIUnknownForObject(newEditor);
     pbstrEditorCaption = "";
     return VSConstants.S_OK;
 }
开发者ID:aTEuCT,项目名称:Repository-Framework,代码行数:28,代码来源:EditorFactory.cs

示例10: TryGetOutputPathFromHierarchy

        private static bool TryGetOutputPathFromHierarchy(IVsHierarchy hierarchy, string containingDirectoryPathOpt, out string binOutputPath)
        {
            binOutputPath = null;
            var storage = hierarchy as IVsBuildPropertyStorage;
            if (storage == null)
            {
                return false;
            }

            if (ErrorHandler.Failed(storage.GetPropertyValue("OutDir", null, (uint)_PersistStorageType.PST_PROJECT_FILE, out var outputDirectory)) ||
                ErrorHandler.Failed(storage.GetPropertyValue("TargetFileName", null, (uint)_PersistStorageType.PST_PROJECT_FILE, out var targetFileName)))
            {
                return false;
            }

            // web app case
            if (!PathUtilities.IsAbsolute(outputDirectory))
            {
                if (containingDirectoryPathOpt == null)
                {
                    return false;
                }

                outputDirectory = FileUtilities.ResolveRelativePath(outputDirectory, containingDirectoryPathOpt);
            }

            binOutputPath = FileUtilities.NormalizeAbsolutePath(Path.Combine(outputDirectory, targetFileName));
            return true;
        }
开发者ID:TyOverby,项目名称:roslyn,代码行数:29,代码来源:AbstractLegacyProject.cs

示例11: AbstractLegacyProject

        public AbstractLegacyProject(
            VisualStudioProjectTracker projectTracker,
            Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
            string projectSystemName,
            IVsHierarchy hierarchy,
            string language,
            IServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
            HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt,
            ICommandLineParserService commandLineParserServiceOpt = null)
            : base(projectTracker,
                  reportExternalErrorCreatorOpt,
                  projectSystemName,
                  projectFilePath: GetProjectFilePath(hierarchy),
                  hierarchy: hierarchy,
                  projectGuid: GetProjectIDGuid(hierarchy),
                  language: language,
                  serviceProvider: serviceProvider,
                  visualStudioWorkspaceOpt: visualStudioWorkspaceOpt,
                  hostDiagnosticUpdateSourceOpt: hostDiagnosticUpdateSourceOpt,
                  commandLineParserServiceOpt: commandLineParserServiceOpt)
        {
            if (Hierarchy != null)
            {
                ConnectHierarchyEvents();
                this.IsWebSite = GetIsWebsiteProject(Hierarchy);
            }

            // Initialize command line arguments.
            base.SetArguments(commandLine: string.Empty);
        }
开发者ID:TyOverby,项目名称:roslyn,代码行数:31,代码来源:AbstractLegacyProject.cs

示例12: OnBeforeCloseProject

 public int OnBeforeCloseProject(IVsHierarchy pHierarchy, int fRemoved)
 {
     var project = pHierarchy as IProjectManager;
     if (project != null)
         project.FixupProject();
     return VSConstants.S_OK;
 }
开发者ID:Hill30,项目名称:F--Project-Extender,代码行数:7,代码来源:Factory.cs

示例13: CPSProject

        public CPSProject(
            VisualStudioProjectTracker projectTracker,
            Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
            string projectDisplayName,
            string projectFilePath,
            IVsHierarchy hierarchy,
            string language,
            Guid projectGuid,
            string commandLineForOptions,
            IServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
            HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt,
            ICommandLineParserService commandLineParserServiceOpt)
            : base(projectTracker, reportExternalErrorCreatorOpt, projectDisplayName, projectFilePath,
                   hierarchy, language, projectGuid, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt)
        {
            // Initialize the options.
            SetCommandLineArguments(commandLineForOptions);

            // We need to ensure that the bin output path for the project has been initialized before we hookup the project with the project tracker.
            // If we were unable to set the output path from SetCommandLineArguments (due to null output file name or directory in the given commandLineForOptions),
            // we set a default unique output path.
            if (this.TryGetBinOutputPath() == null)
            {
                var uniqueDefaultOutputPath = PathUtilities.CombinePathsUnchecked(Path.GetTempPath(), projectDisplayName + projectGuid.GetHashCode().ToString());
                SetOutputPathAndRelatedData(objOutputPath: uniqueDefaultOutputPath, hasSameBinAndObjOutputPaths: true);
            }

            Contract.ThrowIfNull(this.TryGetBinOutputPath());

            // Now hook up the project to the project tracker.
            projectTracker.AddProject(this);

            _lastDesignTimeBuildSucceeded = true;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:35,代码来源:CPSProject.cs

示例14: GetCanonicalName

        public static string GetCanonicalName(uint itemId, IVsHierarchy hierarchy)
        {
            string strRet = string.Empty;
            int hr = hierarchy.GetCanonicalName(itemId, out strRet);

            if (hr == VSConstants.E_NOTIMPL)
            {
                // Special case E_NOTIMLP to avoid perf hit to throw an exception.
                return string.Empty;
            }
            else
            {
                try
                {
                    ErrorHandler.ThrowOnFailure(hr);
                }
                catch (System.Runtime.InteropServices.COMException)
                {
                    strRet = string.Empty;
                }

                // This could be in the case of S_OK, S_FALSE, etc.
                return strRet;
            }
        }
开发者ID:Tokiota,项目名称:PildorasALM,代码行数:25,代码来源:VsSolutionHelper.cs

示例15: OnAfterLastDocumentUnlock

        public int OnAfterLastDocumentUnlock(IVsHierarchy pHier, uint itemid, string pszMkDocument, int fClosedWithoutSaving)
        {
            //The close initiated in OnAfterSave will cause an additional call here for the .diagram file.
            if (EDMXFileTools.EdmxTools.RefreshOnSaveEnabled && !String.IsNullOrEmpty(closingDocument))
            {
                if (pszMkDocument.Equals(closingDocument))
                {
                    try
                    {
                        DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE;

                        //Now the file is closed we need to iterate to find it.
                        foreach (Project proj in dte.Solution.Projects)
                        {
                            foreach (ProjectItem item in proj.ProjectItems)
                            {
                                if (item.FileNames[0].Equals(closingDocument))
                                {
                                    if (!item.IsOpen)
                                        item.Open().Activate();
                                    closingDocument = String.Empty;
                                    return VSConstants.S_OK;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(String.Format("EdmxFileTools Error reactivating {0}, {1}", closingDocument, ex.Message));
                    }
                }
            }
            return VSConstants.S_OK;
        }
开发者ID:jradxl,项目名称:Generate-Database-Edmx-Automation,代码行数:34,代码来源:GenDBAutomationPackage.cs


注:本文中的IVsHierarchy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。