C# 从属性窗口获取属性
我正在创建Visual Studio外接程序,当我在服务器资源管理器窗口(或数据表或数据字段)中选择数据连接节点时,是否有方法使用EnvDTE从Visual Studio中显示的属性窗口获取属性值 我需要从以下字段获取这些值:C# 从属性窗口获取属性,c#,visual-studio-2013,envdte,vs-extensibility,C#,Visual Studio 2013,Envdte,Vs Extensibility,我正在创建Visual Studio外接程序,当我在服务器资源管理器窗口(或数据表或数据字段)中选择数据连接节点时,是否有方法使用EnvDTE从Visual Studio中显示的属性窗口获取属性值 我需要从以下字段获取这些值:连接字符串,提供程序,数据类型,是标识,等等 thnx previous以下是一些示例代码,演示如何访问属性网格中的选择。注意:可以选择多个对象,而不仅仅是一个: IVsMonitorSelection selection = (IVsMonitorSelection)yo
连接字符串
,提供程序
,数据类型
,是标识
,等等
thnx previous以下是一些示例代码,演示如何访问属性网格中的选择。注意:可以选择多个对象,而不仅仅是一个:
IVsMonitorSelection selection = (IVsMonitorSelection)yourSite.GetService(typeof(SVsShellMonitorSelection)); // or yourPackage.GetGlobalService
IVsMultiItemSelect ms;
IntPtr h;
IntPtr pp;
uint itemid;
selection.GetCurrentSelection(out h, out itemid, out ms, out pp);
if (pp != IntPtr.Zero)
{
try
{
ISelectionContainer container = Marshal.GetObjectForIUnknown(pp) as ISelectionContainer;
if (container != null)
{
uint count;
container.CountObjects((uint)Microsoft.VisualStudio.Shell.Interop.Constants.GETOBJS_SELECTED, out count);
if (count == 1)
{
object[] objs = new object[1];
container.GetObjects((uint)Microsoft.VisualStudio.Shell.Interop.Constants.GETOBJS_SELECTED, 1, objs);
object selection = objs[0]; // selection is here
}
}
}
finally
{
Marshal.Release(pp);
}
}
就这样。。我到达ISelectionContainer接口,然后Marshal杀了我:)