A set of helper methods for dealing with expressions
InheritanceSystem.Object
Namespace: Umbraco.Cms.Core Assembly: Umbraco.Core.dll Syntaxpublic static class ExpressionHelper
Methods View Source FindProperty(LambdaExpression) Declaration
public static (MemberInfo, string) FindProperty(LambdaExpression lambda)
Parameters Type Name Description System.Linq.Expressions.LambdaExpression lambda Returns Type Description System.ValueTuple<System.Reflection.MemberInfo, System.String> View Source GetFirstValueFromArguments(IEnumerable<Expression>)
Gets the first value from the supplied arguments of an expression, for those arguments that can be cast to System.Linq.Expressions.ConstantExpression.
Declarationpublic static object GetFirstValueFromArguments(IEnumerable<Expression> arguments)
Parameters Type Name Description IEnumerable<System.Linq.Expressions.Expression> arguments
The arguments.
Returns Type Description System.Object View Source GetMember(Expression)Gets a System.Reflection.MemberInfo from an System.Linq.Expressions.Expression provided it refers to member access.
Declarationpublic static MemberInfo GetMember(Expression expression)
Parameters Type Name Description System.Linq.Expressions.Expression expression
The expression.
Returns Type Description System.Reflection.MemberInfo View Source GetMemberInfo<T, TReturn>(Expression<Func<T, TReturn>>)Gets a System.Reflection.MemberInfo from an System.Linq.Expressions.Expression<TDelegate> of provided it refers to member access.
Declarationpublic static MemberInfo GetMemberInfo<T, TReturn>(Expression<Func<T, TReturn>> fromExpression)
Parameters Type Name Description System.Linq.Expressions.Expression<Func<T, TReturn>> fromExpression
From expression.
Returns Type Description System.Reflection.MemberInfoThe System.Reflection.MemberInfo or null if fromExpression
cannot be converted to System.Linq.Expressions.MemberExpression.
The type of the return.
View Source GetMethod(Expression)Gets a System.Reflection.MethodInfo from an System.Linq.Expressions.Expression provided it refers to a method call.
Declarationpublic static MethodInfo GetMethod(Expression expression)
Parameters Type Name Description System.Linq.Expressions.Expression expression
The expression.
Returns Type Description System.Reflection.MethodInfoThe System.Reflection.MethodInfo or null if expression
cannot be converted to System.Linq.Expressions.MethodCallExpression.
Gets a System.Reflection.MethodInfo from an System.Linq.Expressions.Expression<TDelegate> of provided it refers to a method call.
Declarationpublic static MethodInfo GetMethodInfo<T>(Expression<Action<T>> fromExpression)
Parameters Type Name Description System.Linq.Expressions.Expression<Action<T>> fromExpression
From expression.
Returns Type Description System.Reflection.MethodInfoThe System.Reflection.MethodInfo or null if fromExpression
is null or cannot be converted to System.Linq.Expressions.MethodCallExpression.
Gets the method info.
Declarationpublic static MethodInfo GetMethodInfo<TReturn>(Expression<Func<TReturn>> fromExpression)
Parameters Type Name Description System.Linq.Expressions.Expression<Func<TReturn>> fromExpression
From expression.
Returns Type Description System.Reflection.MethodInfo Type Parameters Name Description TReturnThe return type of the method.
View Source GetMethodInfo<T1, T2>(Expression<Func<T1, T2>>)Gets the method info.
Declarationpublic static MethodInfo GetMethodInfo<T1, T2>(Expression<Func<T1, T2>> fromExpression)
Parameters Type Name Description System.Linq.Expressions.Expression<Func<T1, T2>> fromExpression
From expression.
Returns Type Description System.Reflection.MethodInfo Type Parameters Name Description T1The type of the 1.
T2The type of the 2.
View Source GetMethodParams<T1, T2>(Expression<Func<T1, T2>>) Declarationpublic static IDictionary<string, object>? GetMethodParams<T1, T2>(Expression<Func<T1, T2>> fromExpression)
Parameters Type Name Description System.Linq.Expressions.Expression<Func<T1, T2>> fromExpression Returns Type Description System.Nullable<IDictionary<System.String, System.Object>> Type Parameters View Source GetPropertyInfo<TSource, TProperty>(TSource, Expression<Func<TSource, TProperty>>)
Gets a System.Reflection.PropertyInfo object from an expression.
Declarationpublic static PropertyInfo GetPropertyInfo<TSource, TProperty>(this TSource source, Expression<Func<TSource, TProperty>> propertyLambda)
Parameters Type Name Description TSource source
The source.
System.Linq.Expressions.Expression<Func<TSource, TProperty>> propertyLambdaThe property lambda.
Returns Type Description System.Reflection.PropertyInfo Type Parameters Name Description TSourceThe type of the source.
TPropertyThe type of the property.
View Source GetPropertyInfo<TSource, TProperty>(Expression<Func<TSource, TProperty>>)Gets a System.Reflection.PropertyInfo object from an expression.
Declarationpublic static PropertyInfo GetPropertyInfo<TSource, TProperty>(Expression<Func<TSource, TProperty>> propertyLambda)
Parameters Type Name Description System.Linq.Expressions.Expression<Func<TSource, TProperty>> propertyLambda
The property lambda.
Returns Type Description System.Reflection.PropertyInfo Type Parameters Name Description TSourceThe type of the source.
TPropertyThe type of the property.
View Source GetStaticMethodInfo(Delegate)Gets a System.Reflection.MethodInfo from a
Declarationpublic static MethodInfo GetStaticMethodInfo(Delegate fromMethodGroup)
Parameters Type Name Description Delegate fromMethodGroup
From method group.
Returns Type Description System.Reflection.MethodInfo View Source IsConstant(Expression)Determines whether the specified expression is a constant.
Declarationpublic static bool IsConstant(Expression expression)
Parameters Type Name Description System.Linq.Expressions.Expression expression
The expression.
Returns Type Description System.Booleantrue
if the specified expression is constant; otherwise, false
.
Determines whether the specified expression is a member.
Declarationpublic static bool IsMember(Expression expression)
Parameters Type Name Description System.Linq.Expressions.Expression expression
The expression.
Returns Type Description System.Booleantrue
if the specified expression is member; otherwise, false
.
Determines whether the specified expression is a method.
Declarationpublic static bool IsMethod(Expression expression)
Parameters Type Name Description System.Linq.Expressions.Expression expression
The expression.
Returns Type Description System.Booleantrue
if the specified expression is method; otherwise, false
.
Determines whether the MethodInfo is the same based on signature, not based on the equality operator or HashCode.
Declarationpublic static bool IsMethodSignatureEqualTo(this MethodInfo left, MethodInfo right)
Parameters Type Name Description System.Reflection.MethodInfo left
The left.
System.Reflection.MethodInfo rightThe right.
Returns Type Description System.Booleantrue
if [is method signature equal to] [the specified left]; otherwise, false
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4