Reflection to get public instance properties in UW

2019-09-11 10:53发布

I am porting a Silverlight application to UWP. In my Silverlight app, i get the public instance properties:

Type t;
t.GetProperties(BindingFlags.Instance | BindingFlags.Public);

In UWP it look like the GetProperties(BindingFlags.Instance | BindingFlags.Public) method is no longer available. Is there another way to accomplish this in UWP?

thank you.

1条回答
forever°为你锁心
2楼-- · 2019-09-11 11:35

From this MSDN source, you can do the following:

var props = t.GetTypeInfo().DeclaredProperties
                           .Where(x => x.GetMethod.IsPublic);
查看更多
登录 后发表回答