src/Shared/EntityFramework/Core/Objects/ELinq/TypeSystem.cs
// <summary>
// Resolves MemberInfo to a property or field.
// </summary>
// <param name="member"> Member to test. </param>
// <param name="name"> Name of member. </param>
// <param name="type"> Type of member. </param>
// <returns> Given member normalized as a property or field. </returns>
Resolves MemberInfo to a property or field.
Resolves MemberInfo to a property or field .
internal static MemberInfo PropertyOrField(MemberInfo member, out string name, out Type type)
        {
            name = null;
            type = null;
            if (member.MemberType == MemberTypes.Field)
            {
                var field = (FieldInfo)member;
                name = field.Name;
                type = field.FieldType;
                return field;
            }
            else if (member.MemberType == MemberTypes.Property)
            {
                var property = (PropertyInfo)member;
                if (0 != property.GetIndexParameters().Length)
                {
                    throw new NotSupportedException(Strings.ELinq_PropertyIndexNotSupported);
                }
                name = property.Name;
                type = property.PropertyType;
                return property;
            }
            else if (member.MemberType == MemberTypes.Method)
            {
                var method = (MethodInfo)member;
                if (method.IsSpecialName) 
                {
                    foreach (var property in method.DeclaringType.GetRuntimeProperties())
                    {
                        if (property.CanRead
                            && (property.Getter() == method))
                        {
                            return PropertyOrField(property, out name, out type);
                        }
                    }
                }
            }
            throw new NotSupportedException(Strings.ELinq_NotPropertyOrField(member.Name));
        }
internal static MemberInfo PropertyOrField ( MemberInfo member , out string name , out Type type ) { name = null ; type = null ; if ( member . MemberType == MemberTypes . Field ) { var field = ( FieldInfo ) member ; name = field . Name ; type = field . FieldType ; return field ; } else if ( member . MemberType == MemberTypes . Property ) { var property = ( PropertyInfo ) member ; if ( 0 != property . GetIndexParameters ( ) . Length ) { throw new NotSupportedException ( Strings . ELinq_PropertyIndexNotSupported ) ; } name = property . Name ; type = property . PropertyType ; return property ; } else if ( member . MemberType == MemberTypes . Method ) { var method = ( MethodInfo ) member ; if ( method . IsSpecialName ) { foreach ( var property in method . DeclaringType . GetRuntimeProperties ( ) ) { if ( property . CanRead && ( property . Getter ( ) == method ) ) { return PropertyOrField ( property , out name , out type ) ; } } } } throw new NotSupportedException ( Strings . ELinq_NotPropertyOrField ( member . Name ) ) ; }
Resolves MemberInfo to a property or field.
Resolves MemberInfo to a property or field .
// don't support indexed properties // this may be a property accessor in disguise (if it's a RuntimeMethodHandle) // property accessor methods must set IsSpecialName // try to find a property with the given getter
Given member normalized as a property or field.
Given member normalized as a property or field .
member
MemberInfo
Member to test.
Member to test .
string
out
Type
out
name
Name of member.
Name of member .
type
Type of member.
Type of member .