I have the code below.
public static IEnumerable<PropertyInfo> GetAllPublicInstanceDeclaredOnlyProperties(this Type type)
{
var result =
from PropertyInfo pi in type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
select pi;
return result;
}
I am trying to convert this to a PCL library but I can not figure it out. I have tried
type.GetTypeInfo().DeclaredProperties.Where(x => x.BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
But BindingFlags doesn't exist.
What am I missing?
According to MSDN, GetProperties
method is supported:
Supported in: Portable Class Library
Make sure you've included System.Reflection
namespace.
GetProperties()
is part of the System.Reflection.TypeExtensions
class (a bunch of reflection extension methods) so include the namespace and you should have this and similar extensions available.
If it's still not available, try include System.Reflection.TypeExtensions
assembly via NuGet.
PM> Install-Package System.Reflection.TypeExtensions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With