internal static List <PropertyInfo> Properties(this Type type, BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance) { // Load Type Fields Into Cache List If They Are Not Already There ClassTypeInformation classInfo = CacheRepository.LoadTypeInformation(type, bindingFlags); // Check Property Cache List For Field By Name List <PropertyInfo> listObjectTypeProperties = (List <PropertyInfo>)classInfo.Members .Select(member => member.PropertyInfo).ToList(); return(listObjectTypeProperties); }
internal static FieldInfo Field(this object obj, string strFieldName, BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Instance) { // Load Type Fields Into Cache List If They Are Not Already There ClassTypeInformation classInfo = CacheRepository.LoadTypeInformation(obj.GetType(), bindingFlags); // Find Field FieldInfo objectTypeField = (FieldInfo)classInfo.Members .Where(member => member.FieldInfo.Name == strFieldName) .Select(member => member.FieldInfo) .FirstOrDefault(); return(objectTypeField); }
internal static List <MemberInfo> Members(this object obj, BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Instance) { // Load Type Fields Into Cache List If They Are Not Already There ClassTypeInformation classInfo = CacheRepository.LoadTypeInformation(obj.GetType(), bindingFlags); List <MemberInfo> listObjectTypeFields = (List <MemberInfo>)classInfo.Members .Select(member => member.MemberInfo).ToList(); // If Field Exists In Cache Return It if (listObjectTypeFields != null) { return(listObjectTypeFields); } listObjectTypeFields = obj.GetType().GetMembers(bindingFlags).ToList(); return(listObjectTypeFields); }
internal static PropertyInfo Property(this object obj, string strPropertyName, BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance) { // Load Type Fields Into Cache List If They Are Not Already There ClassTypeInformation classInfo = CacheRepository.LoadTypeInformation(obj.GetType(), bindingFlags); // Check Property Cache List For Property By Name PropertyInfo objectTypeProperty = (PropertyInfo)classInfo.Members .Where(member => member.PropertyInfo.Name == strPropertyName) .Select(member => member.PropertyInfo) .FirstOrDefault(); // If Property Exists In Cache Return It if (objectTypeProperty != null) { return(objectTypeProperty); } objectTypeProperty = obj.Properties(bindingFlags) .Where(property => property.Name == strPropertyName).FirstOrDefault(); return(objectTypeProperty); }
internal static MemberInfo Member(this object obj, string strFieldName, BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Instance) { // Load Type Fields Into Cache List If They Are Not Already There ClassTypeInformation classInfo = CacheRepository.LoadTypeInformation(obj.GetType(), bindingFlags); // Find Field MemberInfo objectTypeField = (MemberInfo)classInfo.Members .Where(member => member.MemberInfo.Name == strFieldName) .Select(member => member.FieldInfo) .FirstOrDefault(); // If Field Exists In Cache Return It if (objectTypeField != null) { return(objectTypeField); } //objectTypeField = obj.GetType().GetFields(bindingFlags) // .Where(field => field.Name == strFieldName).FirstOrDefault(); return(objectTypeField); }