Class ExpressionHelper
- Namespace
- Bonsai
- Assembly
- Bonsai.Core.dll
Provides a set of static methods to manipulate expression trees.
public static class ExpressionHelper
- Inheritance
-
ExpressionHelper
- Inherited Members
Fields
ArgumentSeparator
Represents the character separating selected members in a member selector expression.
public const string ArgumentSeparator = ","
Field Value
ImplicitParameterName
Represents the name of the implicit parameter in a member selector expression.
public const string ImplicitParameterName = "it"
Field Value
MemberSeparator
Represents the character separating class members in a member selector expression.
public const string MemberSeparator = "."
Field Value
Methods
GetGenericTypeBindings(Type, Type)
Returns an array of Type objects that represent the bounded type parameters resulting from matching the specified generic type with a concrete type.
public static Type[] GetGenericTypeBindings(Type genericType, Type type)
Parameters
genericType
TypeThe generic type definition used to test for bindings.
type
TypeThe Type used to bind against
genericType
.
Returns
- Type[]
The array of Type objects representing the bounded type parameters, or an empty array, in case no compatible bindings are found.
IsCollectionType(Type)
Tests whether the specified type implements a serialization compatible collection.
public static bool IsCollectionType(Type type)
Parameters
Returns
IsEnumerableType(Type)
Tests whether the specified type implements the generic enumerable interface.
public static bool IsEnumerableType(Type type)
Parameters
Returns
MemberAccess(Expression, string)
Creates an Expression representing a chained access to a member variable.
public static Expression MemberAccess(Expression instance, string memberPath)
Parameters
instance
ExpressionThe object to which the member chain belongs.
memberPath
stringThe path to an inner member variable, separated by a dot. Indexed accessors are also allowed.
Returns
- Expression
The created Expression.
Parse(Expression, string)
Creates an Expression representing the result of parsing a string with the specified pattern.
public static Expression Parse(Expression expression, string pattern)
Parameters
expression
ExpressionAn Expression that represents the string to parse.
pattern
stringThe parse pattern to match, including data type format specifiers. If
pattern
is null, the input string is returned.
Returns
- Expression
An Expression that represents the result of parsing the specified string.
Parse(Expression, string, params string[])
Creates an Expression representing the result of first splitting a string using separator tokens and then parsing each of the elements against the specified pattern.
public static Expression Parse(Expression expression, string pattern, params string[] separator)
Parameters
expression
ExpressionAn Expression that represents the string to parse.
pattern
stringThe parse pattern to match, including data type format specifiers. If
pattern
is null, each of the resulting element strings is returned unchanged.separator
string[]An optional array of delimiters used for splitting the string into individual elements before parsing. If the array is empty, the input string is parsed directly without further processing.
Returns
- Expression
An Expression that represents the result of splitting and parsing the specified string. If a separator array is specified, the resulting expression will be of type Array.
SelectMemberNames(string)
Extracts the set of member accessor paths from a composite selector string.
public static IEnumerable<string> SelectMemberNames(string selector)
Parameters
selector
stringThe comma-separated selector string used to extract multiple members.
Returns
- IEnumerable<string>
An enumerator of the set of member accessor paths extracted from the composite selector string.
SelectMembers(Expression, string)
Returns the set of member selector expressions specified by a composite selector string.
public static IEnumerable<Expression> SelectMembers(Expression expression, string selector)
Parameters
expression
ExpressionThe object to which the members belong.
selector
stringThe comma-separated selector string used to extract multiple members.
Returns
- IEnumerable<Expression>
A set of Expression instances representing the member variables accessed by the composite selector string.