c# - Missing something in this method to get the Entity property -


private string[] getproperties(econtent_econtentfields econtentfield) {     list<string> list = new list<string>();     type fieldtype = econtentfield.gettype();     var properties = fieldtype.getproperties();     foreach (var prop in properties)     {         if (prop.membertype == membertypes.property)         {             if (prop.propertytype.isgenerictype)             {                 dynamic items = prop.getvalue(econtentfield, null);                 foreach (var item in items)                 {                     type typeitem = item.gettype();                     list.add(item);                 }             }         }     }      return list.toarray(); } 

this method retrieve array of strings properties of entity statement:

if (prop.propertytype.isgenerictype) 

it's false. i've copy-pasted code maybe i'm missing something. can't see.

var result = new list<string>(); var type = econtentfield.gettype(); foreach (var prop in type.getproperties()) {      result.add(prop.name);  }   return result.toarray(); } 

this twice faster method, if interested in speed. ps: if change foreach loop, wil bit faster, not lot :)


Comments

Popular posts from this blog

gcc - MinGW's ld cannot perform PE operations on non PE output file -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -