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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -