System.Linq.Expressions.Error.NotAMemberOfType C# (CSharp) Method

NotAMemberOfType() static private method

ArgumentException with message like "'{0}' is not a member of type '{1}'"
static private NotAMemberOfType ( object p0, object p1, string paramName ) : Exception
p0 object
p1 object
paramName string
return Exception
        internal static Exception NotAMemberOfType(object p0, object p1, string paramName)
        {
            return new ArgumentException(Strings.NotAMemberOfType(p0, p1), paramName);
        }
        /// <summary>

Same methods

Error::NotAMemberOfType ( object p0, object p1, string paramName, int index ) : Exception

Usage Example

Beispiel #1
0
        /// <summary>
        /// Creates a <see cref="MemberExpression"/> accessing a property or field.
        /// </summary>
        /// <param name="expression">The containing object of the member.  This can be null for static members.</param>
        /// <param name="propertyOrFieldName">The member to be accessed.</param>
        /// <returns>The created <see cref="MemberExpression"/>.</returns>
        public static MemberExpression PropertyOrField(Expression expression, string propertyOrFieldName)
        {
            RequiresCanRead(expression, "expression");
            // bind to public names first
            var pi = expression.Type.GetProperty(propertyOrFieldName, _publicFlags);

            if (pi != null)
            {
                return(Property(expression, pi));
            }

            var fi = expression.Type.GetField(propertyOrFieldName, _publicFlags);

            if (fi != null)
            {
                return(Field(expression, fi));
            }

            pi = expression.Type.GetProperty(propertyOrFieldName, _nonPublicFlags);
            if (pi != null)
            {
                return(Property(expression, pi));
            }

            fi = expression.Type.GetField(propertyOrFieldName, _nonPublicFlags);
            if (fi != null)
            {
                return(Field(expression, fi));
            }

            throw Error.NotAMemberOfType(propertyOrFieldName, expression.Type);
        }
All Usage Examples Of System.Linq.Expressions.Error::NotAMemberOfType
Error