Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }