0
我創建了一個Visual Studio加載項,並且當我在服務器資源管理器窗口(或數據表或數據字段)中選擇數據連接節點時,是否有方法從屬性窗口中獲取屬性值使用EnvDTE的視覺工作室?從屬性窗口獲取屬性
我需要從這些領域獲取這些值:提前
我創建了一個Visual Studio加載項,並且當我在服務器資源管理器窗口(或數據表或數據字段)中選擇數據連接節點時,是否有方法從屬性窗口中獲取屬性值使用EnvDTE的視覺工作室?從屬性窗口獲取屬性
我需要從這些領域獲取這些值:提前
這裏Connection string
,Provider
,Data type
,Is Identity
等
日Thnx的是,演示如何訪問屬性的選擇一些示例代碼格。請注意,可以選擇多個對象,不僅有一個:
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界面,然後元帥殺了我:) – murga