364
❘
CHAPTER 17
ExtEnding ironPython Using VisUal Basic.nEt
FIgURE 17-2:
The dir() function shows the content of the Calcs class.
Adding the IronPython Project
At this point, you have a Visual Basic.NET extension (or module) to use with IronPython. Of course,
you’ll want to test it. The easiest way to do this is to add the IronPython project directly to the current
solution. The following steps describe how to perform this task.
1.
Right-click the solution entry in Solution Explorer and choose Add
➤➤➪➤➤
Existing Project from
the context menu. You’ll see the Add Existing Project dialog box shown in Figure 17-3.
FIgURE 17-3:
Locate IPY.EXE and add it to your solution.
548592c17.indd 364
2/24/10 12:49:34 PM
www.finebook.ir
Creating the Simple Visual Basic.NET Extension
❘
365
2.
Locate
IPY.EXE
on your hard drive and highlight it. Click Open. You’ll see a new project
entry added to the solution.
3.
Right-click the ipy entry in Solution Explorer and choose Set as Startup Project from the con-
text menu. This step ensures that choosing one of the startup options from the Debug menu
starts the IronPython application.
4.
Right-click the ipy entry in Solution Explorer and choose Properties from the context menu.
You’ll see the General tab of the ipy Properties window shown in Figure 17-4.
FIgURE 17-4:
Configure the IronPython application to work with Calcs.DLL.
5.
Type -D TestCalcs.py in the Arguments field.
6.
Click the ellipses in the Working Directory field to display the Browse for Folder dialog box.
Locate the output folder of the
Calcs.DLL
(or other extension) file. Click OK. The IDE adds
the correct directory information to the Working Directory field.
7.
Open Windows Explorer. Locate the
\Calcs\Calcs\bin\Debug
folder. Right-click in
the right pane and choose New
➤➤➪➤➤
Text Document from the context menu. Name the file
TestCalcs.py
and press Enter. Click Yes if asked if you want to rename the file extension.
8.
Right-click the solution item in Solution Explorer and choose Add
➤➤➪➤➤
Existing Item from the
context menu to display the Add Existing Item dialog box shown in Figure 17-5.
9.
Locate the
TestCalcs.py
file in the solution and click Add. Visual Studio adds
TestCalcs.py
to the
Solution Items
folder in Solution Explorer and automatically opens the file for you.
You’re ready to add test code for the application.
548592c17.indd 365
2/24/10 12:49:34 PM
www.finebook.ir
Do'stlaringiz bilan baham: |