[英]Call function of Visual Studio Package
I have created a new Visual Studio Package that when loaded creates a Tool Window that looks like this: 我创建了一个新的Visual Studio包,该包在加载时会创建一个如下所示的“工具”窗口:
It is comprised of some controls with canvases and such that draw shapes in 2 or 3 dimensions. 它由一些带有画布的控件组成,并且可以绘制2或3维的形状。 Right now they work in the initialization step to create the objects you see above.
现在,它们在初始化步骤中工作,以创建您在上面看到的对象。 For this tool to be useful I would like to call a method on those controls to pass it other objects to draw.
为了使该工具有用,我想在这些控件上调用一个方法以将其传递给其他对象以进行绘制。 For example, I am debugging some code with points and lines and want to see them graphically.
例如,我正在调试一些带有点和线的代码,并希望以图形方式查看它们。 (Perhaps using the Immeadiate Window? or something similar?) I would like to be able to call GeometryVisualToolWindow.DrawObject(myCircle);
(也许使用Immeadiate窗口?还是类似的东西?)我希望能够调用GeometryVisualToolWindow.DrawObject(myCircle);
How can I access public methods within the package and pass arguments? 如何访问包中的公共方法并传递参数?
I don't want to use a debugger visualizer because I want to be able to selectively add and remove objects from the scene, where a debugger visualizer will only show the single object. 我不想使用调试器可视化器,因为我希望能够选择性地从场景中添加和删除对象,而调试器可视化器将仅显示单个对象。 (eg I want to see if two lines intersect, etc.)
(例如,我想看看两条线是否相交,等等。)
I have attempted to use DTE.Debugger.GetExpression
to solve the problem but after adding the appropriate references, I get this: 我试图使用
DTE.Debugger.GetExpression
解决问题,但是在添加了适当的引用之后,我得到了:
I'll give you an idea how to execute arbitrary code in visual studio debugging session. 我会给你一个想法,如何在Visual Studio调试会话中执行任意代码。
See automation model: http://i.msdn.microsoft.com/dynimg/IC75297.gif 请参阅自动化模型: http : //i.msdn.microsoft.com/dynimg/IC75297.gif
You have access to the instance of DTE.Debugger , this is described here: http://msdn.microsoft.com/en-us/library/aa291845(v=vs.71).aspx (Visual Studio Debugger Object Model). 您可以访问DTE.Debugger的实例,在这里对此进行了描述: http : //msdn.microsoft.com/zh-cn/library/aa291845 ( v=vs.71) .aspx (Visual Studio调试器对象模型)。
You then can choose: 然后,您可以选择:
1) Execute the actual statement in VS debugger( ExecuteStatement
). 1)在VS调试器(
ExecuteStatement
)中执行实际的语句。 This means you need to take care of loading all your assemblies into specific debugger session. 这意味着您需要注意将所有程序集加载到特定的调试器会话中。 The loaded assembly needs to take care of adding static function that user can call.
加载的程序集需要注意添加用户可以调用的静态函数。 Such as
GeometryVisualToolWindow.DrawObject(myCircle);
如
GeometryVisualToolWindow.DrawObject(myCircle);
. 。 The method needs to communicate with VSPackage.
该方法需要与VSPackage通信。
OR 要么
2) Use GetExpression("myVariable.SerializeToBase64()") from your VSPackage, and voila, you have serialized instance of your myVariable
. 2)使用VSPackage中的GetExpression(“ myVariable.SerializeToBase64()”),瞧,您已经序列化了
myVariable
实例。 Ofcourse, you first need to inject such functionality. 当然,您首先需要注入这样的功能。
http://msdn.microsoft.com/en-us/library/aa291625(v=vs.71).aspx http://msdn.microsoft.com/en-us/library/aa291625(v=vs.71).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.