PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.ExpressionUtil Class Reference

Utility class to assist with dealing with expressions. More...

Static Public Member Functions

static string GetMemberPathFor< TSource > (Expression< Func< TSource, object > > expression)
 Calculates the member path of an Expression and returns it as a dotted string.
static Type GetPropertyTypeFor< TSource > (Expression< Func< TSource, object > > expression)
 Gets the type of the property referred to by an expression.
static string GetFullPropertyPathNameFrom (MemberExpression expression)
 Calculates the member path of an Expression and returns it as a dotted string.

Detailed Description

Utility class to assist with dealing with expressions.

Member Function Documentation

◆ GetFullPropertyPathNameFrom()

string PeanutButter.Utils.ExpressionUtil.GetFullPropertyPathNameFrom ( MemberExpression expression)
static

Calculates the member path of an Expression and returns it as a dotted string.

Parameters
expressionSubject Expression to operate on
Returns
(Dotted) string representing the path in the expression
  • for example, the expression o => o.Foo.Bar will return "Foo.Bar"

◆ GetMemberPathFor< TSource >()

string PeanutButter.Utils.ExpressionUtil.GetMemberPathFor< TSource > ( Expression< Func< TSource, object > > expression)
static

Calculates the member path of an Expression and returns it as a dotted string.

Parameters
expressionSubject Expression to operate on
Template Parameters
TSourceType of the source object for the expression
Returns
(Dotted) string representing the path in the expression
  • for example, the expression o => o.Foo.Bar will return "Foo.Bar"
Exceptions
ExceptionExceptions are thrown when the Expression cannot be grokked. The Exception message will explain why.

◆ GetPropertyTypeFor< TSource >()

Type PeanutButter.Utils.ExpressionUtil.GetPropertyTypeFor< TSource > ( Expression< Func< TSource, object > > expression)
static

Gets the type of the property referred to by an expression.

Parameters
expressionSubject expression to operate on
Template Parameters
TSourceType of the source object of the expression
Returns
The type of the property referred to in the expression. For example, o => o.Name would probably return string

The documentation for this class was generated from the following file:
  • source/Utils/PeanutButter.Utils/ExpressionUtil.cs