Table of Contents

Interface IResolver

Namespace
Utils.Expressions
Assembly
Utils.dll

Provides functionality to resolve types, constructors, methods, and members at runtime, as well as to manage constants in expressions.

public interface IResolver
Extension Methods

Methods

GetConstructors(Type)

Retrieves all public constructors for the specified type.

ConstructorInfo[] GetConstructors(Type type)

Parameters

type Type

The Type whose constructors are retrieved.

Returns

ConstructorInfo[]

An array of ConstructorInfo objects.

GetInstanceMethods(Type, string)

Retrieves a list of instance methods on the specified type that match the given method name.

MethodInfo[] GetInstanceMethods(Type type, string name)

Parameters

type Type

The target Type.

name string

The name of the desired instance methods.

Returns

MethodInfo[]

An array of MethodInfo objects representing the matching methods.

GetInstancePropertyOrField(Type, string)

Retrieves an instance property or field on the specified type, by name.

MemberInfo GetInstancePropertyOrField(Type type, string name)

Parameters

type Type

The target Type.

name string

The property or field name.

Returns

MemberInfo

A MemberInfo representing the instance property or field, or null if it cannot be found.

GetStaticMethods(Type, string)

Retrieves a list of static methods on the specified type that match the given method name.

MethodInfo[] GetStaticMethods(Type type, string name)

Parameters

type Type

The target Type.

name string

The name of the desired static methods.

Returns

MethodInfo[]

An array of MethodInfo objects representing the matching methods.

GetStaticPropertyOrField(Type, string)

Retrieves a static property or field on the specified type, by name.

MemberInfo GetStaticPropertyOrField(Type type, string name)

Parameters

type Type

The target Type.

name string

The property or field name.

Returns

MemberInfo

A MemberInfo representing the static property or field, or null if it cannot be found.

ResolveType(string)

Attempts to resolve a type by its name.

Type ResolveType(string name)

Parameters

name string

The name of the type to resolve, potentially including a namespace.

Returns

Type

A Type object if resolution is successful; otherwise null.

ResolveType(string, Type[])

Attempts to resolve a generic type by its name, using the provided generic parameters.

Type ResolveType(string name, Type[] genericParameters)

Parameters

name string

The name of the type to resolve.

genericParameters Type[]

An array of types to use as generic arguments.

Returns

Type

A constructed Type object if resolution is successful; otherwise null.

SelectConstructor(IEnumerable<ConstructorInfo>, Expression[])

Attempts to select the best matching constructor from a collection, given an array of argument expressions.

(ConstructorInfo Method, Expression[] Parameters)? SelectConstructor(IEnumerable<ConstructorInfo> constructors, Expression[] arguments)

Parameters

constructors IEnumerable<ConstructorInfo>

An enumerable of candidate ConstructorInfo objects.

arguments Expression[]

The expressions representing constructor arguments.

Returns

(ConstructorInfo Method, Expression[] Parameters)?

A tuple of (ConstructorInfo, Expression[]) if a suitable match is found; otherwise null.

SelectMethod(IEnumerable<MethodInfo>, Expression, Type[], Expression[])

Attempts to select the best matching method from a collection, given a target (object expression), optional generic parameters, and an array of argument expressions.

(MethodInfo Method, Expression[] Parameters)? SelectMethod(IEnumerable<MethodInfo> methods, Expression obj, Type[] genericParameters, Expression[] arguments)

Parameters

methods IEnumerable<MethodInfo>

An enumerable of candidate MethodInfo objects.

obj Expression

An expression for the method's target object, or null for static methods.

genericParameters Type[]

An optional array of generic arguments for a generic method.

arguments Expression[]

Expressions representing the method arguments.

Returns

(MethodInfo Method, Expression[] Parameters)?

A tuple of (MethodInfo, Expression[]) if a suitable match is found; otherwise null.

TryGetConstant(string, out ConstantExpression)

Attempts to retrieve a constant expression associated with the specified name.

bool TryGetConstant(string name, out ConstantExpression constantExpression)

Parameters

name string

The name that might correspond to a constant value.

constantExpression ConstantExpression

When this method returns, contains a ConstantExpression if one was found; otherwise null.

Returns

bool

true if the constant was found; otherwise false.