예제 #1
0
        /// <summary>
        /// Checks whether the body of the lambda expression is a property indexer, which is true
        /// when the expression is an <see cref="MethodCallExpression"/> whose
        /// <see cref="MethodCallExpression.Method"/> has <see cref="MethodBase.IsSpecialName"/>
        /// equal to <see langword="true"/>.
        /// </summary>
        public static bool IsPropertyIndexer(this LambdaExpression expression)
        {
            Guard.NotNull(expression, nameof(expression));

            return(expression.Body is MethodCallExpression methodCallExpression && methodCallExpression.Method.IsSpecialName);
        }
예제 #2
0
        /// <summary>
        /// Checks whether the body of the lambda expression is a property access.
        /// </summary>
        public static bool IsProperty(this LambdaExpression expression)
        {
            Guard.NotNull(expression, nameof(expression));

            return(expression.Body is MemberExpression memberExpression && memberExpression.Member is PropertyInfo);
        }