Table of Contents

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

string

ImplicitParameterName

Represents the name of the implicit parameter in a member selector expression.

public const string ImplicitParameterName = "it"

Field Value

string

MemberSeparator

Represents the character separating class members in a member selector expression.

public const string MemberSeparator = "."

Field Value

string

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 Type

The generic type definition used to test for bindings.

type Type

The 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

type Type

The Type to test.

Returns

bool

true if the type implements a serialization compatible collection; otherwise, false.

IsEnumerableType(Type)

Tests whether the specified type implements the generic enumerable interface.

public static bool IsEnumerableType(Type type)

Parameters

type Type

The Type to test.

Returns

bool

true if the type implements the generic enumerable interface; otherwise, false.

MemberAccess(Expression, string)

Creates an Expression representing a chained access to a member variable.

public static Expression MemberAccess(Expression instance, string memberPath)

Parameters

instance Expression

The object to which the member chain belongs.

memberPath string

The 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 Expression

An Expression that represents the string to parse.

pattern string

The 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 Expression

An Expression that represents the string to parse.

pattern string

The 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 string

The 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 Expression

The object to which the members belong.

selector string

The 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.