Class ExpressionHelper
A set of helper methods for dealing with expressions
Inheritance
Namespace: Umbraco.Cms.Core
Assembly: Umbraco.Core.dll
Syntax
public static class ExpressionHelper : object
Methods
View SourceFindProperty(LambdaExpression)
Declaration
public static (MemberInfo, string) FindProperty(LambdaExpression lambda)
Parameters
Type | Name | Description |
---|---|---|
LambdaExpression | lambda |
Returns
Type | Description |
---|---|
System.ValueTuple<MemberInfo, System.String> |
GetFirstValueFromArguments(IEnumerable<Expression>)
Gets the first value from the supplied arguments of an expression, for those arguments that can be cast to
Declaration
public static object GetFirstValueFromArguments(IEnumerable<Expression> arguments)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Expression> | arguments | The arguments. |
Returns
Type | Description |
---|---|
System.Object |
GetMember(Expression)
Gets a
Declaration
public static MemberInfo GetMember(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
MemberInfo |
GetMemberInfo<T, TReturn>(Expression<Func<T, TReturn>>)
Gets a
Declaration
public static MemberInfo GetMemberInfo<T, TReturn>(Expression<Func<T, TReturn>> fromExpression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<T, TReturn>> | fromExpression | From expression. |
Returns
Type | Description |
---|---|
MemberInfo | The |
Type Parameters
Name | Description |
---|---|
T | |
TReturn | The type of the return. |
GetMethod(Expression)
Gets a
Declaration
public static MethodInfo GetMethod(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
MethodInfo | The |
GetMethodInfo<T>(Expression<Action<T>>)
Gets a
Declaration
public static MethodInfo GetMethodInfo<T>(Expression<Action<T>> fromExpression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Action<T>> | fromExpression | From expression. |
Returns
Type | Description |
---|---|
MethodInfo | The |
Type Parameters
Name | Description |
---|---|
T |
GetMethodInfo<TReturn>(Expression<Func<TReturn>>)
Gets the method info.
Declaration
public static MethodInfo GetMethodInfo<TReturn>(Expression<Func<TReturn>> fromExpression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TReturn>> | fromExpression | From expression. |
Returns
Type | Description |
---|---|
MethodInfo |
Type Parameters
Name | Description |
---|---|
TReturn | The return type of the method. |
GetMethodInfo<T1, T2>(Expression<Func<T1, T2>>)
Gets the method info.
Declaration
public static MethodInfo GetMethodInfo<T1, T2>(Expression<Func<T1, T2>> fromExpression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<T1, T2>> | fromExpression | From expression. |
Returns
Type | Description |
---|---|
MethodInfo |
Type Parameters
Name | Description |
---|---|
T1 | The type of the 1. |
T2 | The type of the 2. |
GetMethodParams<T1, T2>(Expression<Func<T1, T2>>)
Declaration
public static IDictionary<string, object> GetMethodParams<T1, T2>(Expression<Func<T1, T2>> fromExpression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<T1, T2>> | fromExpression |
Returns
Type | Description |
---|---|
IDictionary<System.String, System.Object> |
Type Parameters
Name | Description |
---|---|
T1 | |
T2 |
GetPropertyInfo<TSource, TProperty>(TSource, Expression<Func<TSource, TProperty>>)
Gets a
Declaration
public static PropertyInfo GetPropertyInfo<TSource, TProperty>(this TSource source, Expression<Func<TSource, TProperty>> propertyLambda)
Parameters
Type | Name | Description |
---|---|---|
TSource | source | The source. |
Expression<Func<TSource, TProperty>> | propertyLambda | The property lambda. |
Returns
Type | Description |
---|---|
PropertyInfo |
Type Parameters
Name | Description |
---|---|
TSource | The type of the source. |
TProperty | The type of the property. |
GetPropertyInfo<TSource, TProperty>(Expression<Func<TSource, TProperty>>)
Gets a
Declaration
public static PropertyInfo GetPropertyInfo<TSource, TProperty>(Expression<Func<TSource, TProperty>> propertyLambda)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TSource, TProperty>> | propertyLambda | The property lambda. |
Returns
Type | Description |
---|---|
PropertyInfo |
Type Parameters
Name | Description |
---|---|
TSource | The type of the source. |
TProperty | The type of the property. |
GetStaticMethodInfo(Delegate)
Gets a
Declaration
public static MethodInfo GetStaticMethodInfo(Delegate fromMethodGroup)
Parameters
Type | Name | Description |
---|---|---|
Delegate | fromMethodGroup | From method group. |
Returns
Type | Description |
---|---|
MethodInfo |
IsConstant(Expression)
Determines whether the specified expression is a constant.
Declaration
public static bool IsConstant(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsMember(Expression)
Determines whether the specified expression is a member.
Declaration
public static bool IsMember(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsMethod(Expression)
Determines whether the specified expression is a method.
Declaration
public static bool IsMethod(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsMethodSignatureEqualTo(MethodInfo, MethodInfo)
Determines whether the MethodInfo is the same based on signature, not based on the equality operator or HashCode.
Declaration
public static bool IsMethodSignatureEqualTo(this MethodInfo left, MethodInfo right)
Parameters
Type | Name | Description |
---|---|---|
MethodInfo | left | The left. |
MethodInfo | right | The right. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
This is useful for comparing Expression methods that may contain different generic types