c# - About ComponentModel and Reflection -


I have a function that accepts an object, then it gets values ​​from properties or fields that have input is.

It currently looks like this:

  Private string GetFieldValue (object o, field F) {//field.name is the name of the property or field MemberInfo [] Mi = o GetType (). GetMember (field.name, member type.fild | member type. Property, bindingflag.instein | binding flag | static | binding flag | public | binding flags.New public | binding flag.exactbinding); If (mi.Length == 0) leave the new argument exception ("field", "member can not be found:" + f.name); Item value; If (miles [0] .MemberType == member type. Property) value = ((propertyInfo = mi [0]). GetValue (O, blank); Other values ​​= ((field info) miles [0]). GetValue (O);  

Today I read about System.ComponentModel and its XXXDescriptor classes. What is the difference, when there is a question of performance, between the 2 framework (Reflection and Component MODEL) Will using the above mentioned component be achieved better performance or flexibility? The only difference between the two which I know, supports the Chief Minister for virtual properties.

Ty

The item difference = "text">

The difference is that componentmodel is an abstract on raw classes. This means that you can define properties those that are not present - and in fact, it is fine that DataView / DataRowView data Highlight the columns as the properties of binding. Using ComponentModel, you can also find something like "dynamic" in 1.1.

You think that component component is slow; But in reality, you can take advantage of this abstract for profit ... it does - reflection. In order to use the AMIT to direct the IL to represent properties, it provides faster access to reflection or vanilla component models.

Note, however, that the component model is limited to properties (by no fields), by default. You can do this through the on-fly property descriptor mask, but this is not a good idea. ComponentModel also has no place for "only written" property.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -