CSharp examples for System.Reflection:PropertyInfo
Is Accessible Property
using System.Reflection; using System.Threading.Tasks; using System.Text; using System.Linq; using System.Collections.Generic; using System;/* ww w .ja v a 2s . co m*/ public class Main{ public static bool IsAccessibleProperty(this PropertyInfo property, bool readCheck, bool writeCheck) { bool result = true; MethodInfo tmp; if (readCheck) { tmp = property.GetMethod; result &= property.CanRead && tmp.IsPublic && !tmp.IsStatic; } if (writeCheck) { tmp = property.SetMethod; result &= property.CanWrite && tmp.IsPublic && !tmp.IsStatic; } return result; } }