Reflection (1) Recognition reflection and reflection Recognition

Source: Internet
Author: User

Reflection (1) Recognition reflection and reflection Recognition

Reflection is a very useful feature in. net.

What is reflection?

It can be summarized in one sentence as follows:Based on assembly and metadata, YesDynamicCreates an instance of a type, calls a method, and accesses an object member.

 

Why use reflection?

Reflection is required when the object to be called cannot be determined during compilation.

 

Application scenarios of reflection

The most common application scenarios are:

1. Database Switching Based on the factory mode.

2. ORM framework, because it faces common models, all attributes or methods are dynamically generated.

3. A plug-in-based system cannot be determined during the compilation period without knowing exactly what the external plug-in is. Therefore, reflection is used for loading.

 

Assembly

Because reflection is based on the Assembly and metadata, it is necessary to explain what is the assembly and when metadata.

Assembly: a program set is a collection of all workers. After compilation, a file (such as executable file .exe and class library file. dll) is generated ).

Metadata: metadata is a part of an assembly and mainly contains information such as name, version, language and culture, and public key tag.

 

Related Article

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.