SSMS 插件 - GetHierarchy 方法为 NULL
SSMS Addin - GetHierarchy Method Is NULL
我正在为 SSMS 2014 编写一个插件。我想获取用于在 ObjectExplorer 中搜索项目的层次结构。
但是 GetHierarchy 方法为空。有人有什么想法吗?
ObjectExplorerService objExplorerService = (ObjectExplorerService)ServiceCache.ServiceProvider.GetService(typeof(IObjectExplorerService));
MethodInfo getHierarchyMethod = objExplorerService.GetType().GetMethod("GetHierarchy", BindingFlags.Instance | BindingFlags.NonPublic);
我找到了问题的答案。我使用以下代码访问了 "Object Explorer Hierarchy"。
List<IExplorerHierarchy> hierarchyList = new List<IExplorerHierarchy>();
ObjectExplorerService objExplorerService = (ObjectExplorerService)ServiceCache.ServiceProvider.GetService(typeof(IObjectExplorerService));
System.Type t = objExplorerService.GetType();
PropertyInfo getHierarchyMethod = t.GetProperty("Tree", BindingFlags.Instance | BindingFlags.NonPublic);
var value = getHierarchyMethod.GetValue(objExplorerService, null);
PropertyInfo getHierarchyMethod2s = value.GetType().GetProperty("Hierarchies", BindingFlags.Instance | BindingFlags.NonPublic);
var value2 = getHierarchyMethod2s.GetValue(value, null);
foreach (var item in (Dictionary<string, IExplorerHierarchy>)value2)
{
hierarchyList.Add(item.Value);
}
我正在为 SSMS 2014 编写一个插件。我想获取用于在 ObjectExplorer 中搜索项目的层次结构。 但是 GetHierarchy 方法为空。有人有什么想法吗?
ObjectExplorerService objExplorerService = (ObjectExplorerService)ServiceCache.ServiceProvider.GetService(typeof(IObjectExplorerService));
MethodInfo getHierarchyMethod = objExplorerService.GetType().GetMethod("GetHierarchy", BindingFlags.Instance | BindingFlags.NonPublic);
我找到了问题的答案。我使用以下代码访问了 "Object Explorer Hierarchy"。
List<IExplorerHierarchy> hierarchyList = new List<IExplorerHierarchy>();
ObjectExplorerService objExplorerService = (ObjectExplorerService)ServiceCache.ServiceProvider.GetService(typeof(IObjectExplorerService));
System.Type t = objExplorerService.GetType();
PropertyInfo getHierarchyMethod = t.GetProperty("Tree", BindingFlags.Instance | BindingFlags.NonPublic);
var value = getHierarchyMethod.GetValue(objExplorerService, null);
PropertyInfo getHierarchyMethod2s = value.GetType().GetProperty("Hierarchies", BindingFlags.Instance | BindingFlags.NonPublic);
var value2 = getHierarchyMethod2s.GetValue(value, null);
foreach (var item in (Dictionary<string, IExplorerHierarchy>)value2)
{
hierarchyList.Add(item.Value);
}