本文整理汇总了C#中IVsHierarchy类的典型用法代码示例。如果您正苦于以下问题:C# IVsHierarchy类的具体用法?C# IVsHierarchy怎么用?C# IVsHierarchy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IVsHierarchy类属于命名空间,在下文中一共展示了IVsHierarchy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: HierarchyListener
public HierarchyListener(IVsHierarchy hierarchy)
{
if (null == hierarchy) {
throw new ArgumentNullException("hierarchy");
}
this.hierarchy = hierarchy;
}
开发者ID:kageyamaginn,项目名称:VSSDK-Extensibility-Samples,代码行数:7,代码来源:HierarchyListener.cs
示例17: if
int IVsPersistSolutionProps.WriteSolutionProps(IVsHierarchy pHierarchy, string pszKey, IPropertyBag pPropBag)
{
if (pHierarchy != null)
return VSConstants.S_OK; // Not send by our code!
else if(pPropBag == null)
return VSConstants.E_POINTER;
// This method is called from the VS implementation after a request from SaveSolutionProps
ISccSettingsStore translate = GetService<ISccSettingsStore>();
IVisualGitSccService scc = GetService<IVisualGitSccService>();
using (IPropertyMap map = translate.GetMap(pPropBag))
{
switch (pszKey)
{
case GitPropertyCategory:
map.SetRawValue(ManagedPropertyName, true.ToString());
// BH: Don't localize this text! Changing it will change all solutions marked as managed by VisualGit
map.SetRawValue(ManagerPropertyName, "VisualGit - Git Support for Visual Studio");
scc.WriteSolutionProperties(map);
break;
case VisualGitId.SccStructureName:
translate.WriteSolutionProperties(map);
break;
}
}
return VSConstants.S_OK;
}
开发者ID:pvginkel,项目名称:VisualGit,代码行数:31,代码来源:VisualGitPackage.SolutionProperties.cs
示例18: CreateEditorInstance
/// <summary>
/// Used by the editor factory to create an editor instance. the environment first determines the
/// editor factory with the highest priority for opening the file and then calls
/// IVsEditorFactory.CreateEditorInstance. If the environment is unable to instantiate the document data
/// in that editor, it will find the editor with the next highest priority and attempt to so that same
/// thing.
/// NOTE: The priority of our editor is 32 as mentioned in the attributes on the package class.
///
/// Since our editor supports opening only a single view for an instance of the document data, if we
/// are requested to open document data that is already instantiated in another editor, or even our
/// editor, we return a value VS_E_INCOMPATIBLEDOCDATA.
/// </summary>
/// <param name="grfCreateDoc">Flags determining when to create the editor. Only open and silent flags
/// are valid
/// </param>
/// <param name="pszMkDocument">path to the file to be opened</param>
/// <param name="pszPhysicalView">name of the physical view</param>
/// <param name="pvHier">pointer to the IVsHierarchy interface</param>
/// <param name="itemid">Item identifier of this editor instance</param>
/// <param name="punkDocDataExisting">This parameter is used to determine if a document buffer
/// (DocData object) has already been created
/// </param>
/// <param name="ppunkDocView">Pointer to the IUnknown interface for the DocView object</param>
/// <param name="ppunkDocData">Pointer to the IUnknown interface for the DocData object</param>
/// <param name="pbstrEditorCaption">Caption mentioned by the editor for the doc window</param>
/// <param name="pguidCmdUI">the Command UI Guid. Any UI element that is visible in the editor has
/// to use this GUID. This is specified in the .vsct file
/// </param>
/// <param name="pgrfCDW">Flags for CreateDocumentWindow</param>
/// <returns></returns>
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)
{
// Initialize to null
ppunkDocView = IntPtr.Zero;
ppunkDocData = IntPtr.Zero;
pguidCmdUI = GuidList.ConfigModuleEditorFactory;
pgrfCDW = 0;
pbstrEditorCaption = null;
// Validate inputs
if ((grfCreateDoc & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0)
{
return VSConstants.E_INVALIDARG;
}
if (punkDocDataExisting != IntPtr.Zero)
{
return VSConstants.VS_E_INCOMPATIBLEDOCDATA;
}
// Create the Document (editor)
ConfigModuleEditorPane editor = new ConfigModuleEditorPane();
ppunkDocView = Marshal.GetIUnknownForObject(editor);
ppunkDocData = Marshal.GetIUnknownForObject(editor);
pbstrEditorCaption = "";
return VSConstants.S_OK;
}
开发者ID:Citringo,项目名称:Prism,代码行数:57,代码来源:ConfigModuleEditorFactory.cs
示例19: CreateCPSProject
// internal for testing purposes only.
internal static CPSProject CreateCPSProject(VisualStudioProjectTracker projectTracker, IServiceProvider serviceProvider, IVsHierarchy hierarchy, string projectDisplayName, string projectFilePath, Guid projectGuid, string language, ICommandLineParserService commandLineParserService, string binOutputPath)
{
return new CPSProject(projectTracker, reportExternalErrorCreatorOpt: null, hierarchy: hierarchy, language: language,
serviceProvider: serviceProvider, visualStudioWorkspaceOpt: null, hostDiagnosticUpdateSourceOpt: null,
projectDisplayName: projectDisplayName, projectFilePath: projectFilePath, projectGuid: projectGuid,
binOutputPath: binOutputPath, commandLineParserServiceOpt: commandLineParserService);
}
开发者ID:orthoxerox,项目名称:roslyn,代码行数:8,代码来源:CPSProjectFactory.cs
示例20: GetProjectItems
public static IEnumerable<string> GetProjectItems(IVsHierarchy project, uint itemId)
{
// Don't enumerate over nodes that have side effects
// This is to prevent errors that could occur since the side affect code can do things like try to
// connect to a db
object hasSideEffects = GetPropertyValue((int)__VSHPROPID.VSHPROPID_HasEnumerationSideEffects, itemId, project);
if (hasSideEffects != null && ((bool) hasSideEffects))
{
yield break;
}
object pVar = GetPropertyValue((int)__VSHPROPID.VSHPROPID_FirstChild, itemId, project);
uint childId = GetItemId(pVar);
while (childId != VSConstants.VSITEMID_NIL)
{
string childPath = GetCanonicalName(childId, project);
yield return childPath;
foreach (var childNodePath in GetProjectItems(project, childId)) yield return childNodePath;
pVar = GetPropertyValue((int)__VSHPROPID.VSHPROPID_NextSibling, childId, project);
childId = GetItemId(pVar);
}
}
开发者ID:squadwuschel,项目名称:chutzpah,代码行数:26,代码来源:VsSolutionHelper.cs
注:本文中的IVsHierarchy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论