Getter and Setter check
using System.Reflection; using System.Data.SqlClient; class Utils { internal static T GetAttribute<T>(ICustomAttributeProvider attributeProvider) { T[] attrs = GetAttributes<T>(attributeProvider); return attrs.Length > 0 ? attrs[0] : default(T); } internal static T[] GetAttributes<T>(ICustomAttributeProvider attributeProvider) { object[] attributes = attributeProvider.GetCustomAttributes(typeof(T), false); T[] ts = new T[attributes.Length]; for (int i = 0; i < attributes.Length; ++i) ts[i] = (T)attributes[i]; return ts; } internal static bool HasGetter(PropertyInfo info) { if (info.GetGetMethod() == null && info.GetGetMethod(true) == null) return false; else return true; } internal static bool HasSetter(PropertyInfo info) { if (info.GetSetMethod() == null && info.GetSetMethod(true) == null) return false; else return true; } internal static bool IsIndexer(PropertyInfo info) { MethodInfo minfo = info.GetGetMethod() == null ? info.GetGetMethod(true) : info.GetGetMethod(); if (minfo.GetParameters().Length > 0) return true; else return false; } }