Reflection in. net

Source: Internet
Author: User

As for reflection, I first read the book and searched the garden. Then I found the war post again. Haha

Colloquial reflection technology-suitable for beginners

Reflection Technology

About the vernacular reflection technology and others (technical) in jizara)

About the vernacular reflection technology and others (quarrel)

 

Well, I know about it after reading it all.

A few days ago, I simply listed the content, and then looked at it roughly. I found it complicated. I also heard that it was not very often used as a low-handed reflection, so I did not read it, in a few days, I forgot to watch the movie. Then I got the cup. The previous day I tried the question "Reflection and serialization "..... I was so depressed for a long time that I only wrote a few words about serialization, and the reflection White was there. (People will never be able to choose the way they are tested)

This piece of knowledge will be completed immediately after you come back, but it is difficult to grasp the reflection in specific application scenarios.

As you can see, reflection is a mechanism to dynamically analyze, manipulate, and create objects at runtime. Reflection is directly dependent on Assembly metadata.

In. in. net, Reflection allows the code to search for the Code itself and analyze, manipulate, and create objects. These objects are not windows, orders, or scattered lists, but in.. net programs.. Net instance. Because every object in the Code is a. Net instance, it means that developers can write code to process any object.

For example, reflection provides a clear and logical method for coding the code to be bound later. This method works even under option strict.

Another example: ASP. NET is a program running on a Web server. When the server receives a webpage request ending with. aspx, it passes the request to the ASP. NET program. ASP. NET identifies the file that contains the code that makes up the page. If this is not done before, compile these files into. Net assembly. This Assembly contains one or more. Net classes, and contains the logic Code required to mark when the request page is passed. ASP. NET is used to create a mechanism for Classes serving specific requests, which depends on reflection to a certain extent. ASP. the. NET page class inherits from the. NET page class. net base class, which contains various functions, used to create all controls that constitute the page by reflection, hook the event handler, and set the required initial attributes for all items that constitute the page. Every ASP. NET page compiled is a new class, but ASP. NET runtime uses reflection to ensure that developers do not have to copy lengthy sample code on every page. In this case, reflection provides a mechanism for code to be reused outside the basic system of class inheritance.

Therefore, reflection is only a foundation, and the key point is how to use reflection for dynamic programming. (To be continued)

20110424 note:

Reflection was recently used in the project, mainly because many methods were found during ut, and many attributes were not easily constructed, or mock came out. Then I directly obtained private member variables using reflection, it is very convenient to directly use reflection to call private methods for testing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.