Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet374/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   370   371   372   373   374   375   376   377   ...   453
8.
Type 
Calcs.VB
for the new filename and press Enter. Visual Studio displays a dialog box that 
asks whether you’d like to rename all of the 
Class1.vb
references to match the new filename.
9.
Click Yes. The project is ready for use.
548592c17.indd 361
2/24/10 12:49:32 PM
www.finebook.ir


362

CHAPTER 17
ExtEnding ironPython Using VisUal Basic.nEt
Renaming the class file also renames any hidden elements. For example, the 
namespace for this project is hidden, but it’s renamed to 
Calcs
. It’s impor-
tant to keep the renaming of hidden elements in mind as you work with the 
IronPython code.
developing the Visual Basic.NET Extension
The Visual Basic.NET extension code for this example is relatively simple. Listing 17-1 shows the 
constructor, operator overrides, and methods used for this example.
LISTINg 17-1: 
 A simple calculations extension
Public Class Calcs
Private Data As Int32
Public Sub New(ByVal Value As Int32)
Me.Data = Value
End Sub
Public Overrides Function ToString() As String
Return Data.ToString()
End Function
Public Shared Operator +(ByVal Value1 As Calcs, _
ByVal Value2 As Calcs) As Calcs
Return New Calcs(Value1.Data + Value2.Data)
End Operator
Public Shared Operator -(ByVal Value1 As Calcs, _
ByVal Value2 As Calcs) As Calcs
Return New Calcs(Value1.Data - Value2.Data)
End Operator
Public Shared Operator *(ByVal Value1 As Calcs, _
ByVal Value2 As Calcs) As Calcs
Return New Calcs(Value1.Data * Value2.Data)
End Operator
Public Shared Operator /(ByVal Value1 As Calcs, _
ByVal Value2 As Calcs) As Calcs
Return New Calcs(Value1.Data / Value2.Data)
End Operator
Public Function Inc() As Calcs
Return New Calcs(Me.Data + 1)
End Function
548592c17.indd 362
2/24/10 12:49:33 PM
www.finebook.ir



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   370   371   372   373   374   375   376   377   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish