Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type.GetProperties() missing in Xamarin PCL

In Xamarin PCL, I'm trying to get the System.Reflection.PropertyInfo of a class I've written so that I can access its properties by their string name to get/set, and Type.GetTypeInfo() is missing, as well as Type.GetProperties. But System.Reflection.PropertyInfo is a valid class. How can I obtain the property info of a class? Do I have to write a wrapper for each platform? (It shows up just fine in the Android/iOS projects).

like image 888
user1054922 Avatar asked Nov 13 '14 12:11

user1054922


1 Answers

It's an extension, so you need to put

using System.Reflection;

at the top. Then it's available:

        TypeInfo typeInfo = this.GetType().GetTypeInfo();
        foreach (PropertyInfo propInfo in typeInfo.DeclaredProperties)
like image 111
user1054922 Avatar answered Oct 15 '22 00:10

user1054922