Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet317/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   313   314   315   316   317   318   319   320   ...   453
LISTINg 14-4: 
 Using the ADynamicObject class
class Test
{
static void Main()
{
// Create a new dynamic object.
dynamic DynObject = new ADynamicObject();
// Set a property to a specific value.
Console.WriteLine(“Setting a Property to a Value”);
DynObject.AProp = 5;
LISTINg 14-3 
(continued)
548592c14.indd 302
2/24/10 12:49:09 PM
www.finebook.ir


Working with IDynamicObject
 

 
303
// Use one property to set another property.
// You would see a property get, followed by a property set.
Console.WriteLine(“\r\nSetting a Property to another Property”);
DynObject.Prop1 = DynObject.AProp;
// Call a method and set its output to a property.
// You would see a method call, followed by a property set.
Console.WriteLine(“\r\nSetting a Property to a Method Output”);
DynObject.Prop2 = DynObject.AMethod();
// Call a method with a property argument and set a new property.
// You would see a property get, a method call, and finally a
// property set.
Console.WriteLine(“\r\nSetting a Property to Method Output with Args”);
DynObject.Prop3 = DynObject.AMethod(DynObject.AProp);
// Wait to see the results.
Console.WriteLine(“\r\nPress any key when ready...”);
Console.ReadLine();
}
}
Notice that the code begins by creating a new dynamic object using the 
dynamic
keyword. At this 
point, you can begin adding properties and methods to the resulting 
DynObject
. Properties can 
receive values directly, from other properties, or from methods. Methods can use arguments to 
change their output. Figure 14-6 shows the output from this example. The path that the code takes 
through the various objects helps you understand how dynamic objects work.
The 
DynamicObject
class actually provides support for a number of members. You can use these 
members to provide a complete dynamic implementation for your application. Here’s a list of the
DynamicObject
members you can override.

GetDynamicMemberNames()

GetMetaObject()


TryBinaryOperation()


TryConvert()


TryDeleteIndex()


TryDeleteMember()


TryGetIndex()


TryGetMember()


TryInvoke()


TryInvokeMember()


TrySetIndex()


TrySetMember()


TryUnaryOperation()


548592c14.indd 303
2/24/10 12:49:09 PM
www.finebook.ir



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   313   314   315   316   317   318   319   320   ...   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