我正在开发一个 Visual Studio 加载项,以使用外部对象调试 BizTalk 地图。我在读取 BizTalk 映射文件(.btm 属性)的现有属性页时遇到了障碍。我能够通过读取文件来读取文件配置。但是我不确定如何阅读属性页。我正在寻找 TestMap 输入实例和 TestMap 输出实例的值。我试过这个,但是 buildPropertyStorage 是空的。
ProjectItem projectItem = _applicationObject.SelectedItems.Item(1).ProjectItem;
string name = "Name";
IVsHierarchy hierarchy;
Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider)_applicationObject;
IntPtr ip;
Guid id1, id2;
id1 = id2 = typeof(SVsSolution).GUID;
int hr = sp.QueryService(ref id1, ref id2, out ip);
IVsSolution solution = (IVsSolution)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(ip);
solution.GetProjectOfUniqueName(projectItem.ContainingProject.UniqueName, out hierarchy);
IVsBuildPropertyStorage buildPropertyStorage = hierarchy as IVsBuildPropertyStorage;
string value = null;
if (buildPropertyStorage != null)
{
uint itemId;
string fullPath = (string)projectItem.Properties.Item("FullPath").Value;
hierarchy.ParseCanonicalName(fullPath, out itemId);
buildPropertyStorage.GetItemAttribute(itemId, name, out value);
}