This print for content only-size & color not accurate 7" X 9-1/4" / casebound / malloy


■ T Y P E   R E F L E C T I O N, L AT E   B I N D I N G, A N D  AT T R I B U T E - B A S E D   P R O G R A M M I N G 542



Download 21,46 Mb.
Pdf ko'rish
bet1052/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   1048   1049   1050   1051   1052   1053   1054   1055   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

T Y P E   R E F L E C T I O N, L AT E   B I N D I N G, A N D  AT T R I B U T E - B A S E D   P R O G R A M M I N G



542

8849CH16.qxd  10/9/07  4:27 PM  Page 542




Attribute Consumers

As you would guess, the .NET 3.5 Framework SDK ships with numerous utilities that are indeed on

the lookout for various attributes. The C# compiler (csc.exe) itself has been preprogrammed to

discover the presence of various attributes during the compilation cycle. For example, if the C#

compiler encounters the [CLSCompliant] attribute, it will automatically check the attributed item to

ensure it is exposing only CLS-compliant constructs. By way of another example, if the C# compiler

discovers an item attributed with the [Obsolete] attribute, it will display a compiler warning in the

Visual Studio 2008 Error List window.

In addition to development tools, numerous methods in the .NET base class libraries are pre-

programmed to reflect over specific attributes. For example, if you wish to persist the state of an

object to file, all you are required to do is annotate your class with the [Serializable] attribute. If

the Serialize() method of the BinaryFormatter class encounters this attribute, the object is auto-

matically persisted to file in a compact binary format.

The .NET CLR is also on the prowl for the presence of certain attributes. Perhaps the most

famous .NET attribute is [WebMethod]. If you wish to expose a method via HTTP requests and auto-

matically encode the method return value as XML, simply apply [WebMethod] to the method and the

CLR handles the details. Beyond web service development, attributes are critical to the operation of

the .NET security system, Windows Communication Foundation, and COM/.NET interoperability

(and so on). 

Finally, you are free to build applications that are programmed to reflect over your own custom

attributes as well as any attribute in the .NET base class libraries. By doing so, you are essentially

able to create a set of “keywords” that are understood by a specific set of assemblies.




Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   1048   1049   1050   1051   1052   1053   1054   1055   ...   1830




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