Table of Contents

Class MemberInfoExtensions

Namespace
DotEx.Reflections
Assembly
DotEx.dll

Extensions for MemberInfo.

public static class MemberInfoExtensions
Inheritance
MemberInfoExtensions
Inherited Members

Methods

GetMemberType(MemberInfo)

Gets the type of this member.

public static Type GetMemberType(this MemberInfo memberInfo)

Parameters

memberInfo MemberInfo

Member info object.

Returns

Type

Type of this member.

Exceptions

ArgumentException

Member other that property, field, or method is provided.

GetValue(MemberInfo, object)

Returns the property/field value of a specified object.

public static object? GetValue(this MemberInfo memberInfo, object target)

Parameters

memberInfo MemberInfo

Member info object

target object

Target object to inspect.

Returns

object

Property of field value.

Exceptions

ArgumentException

Member other that property or field is provided.

IsDefined<TAttribute>(MemberInfo)

Indicates whether custom attributes of a specified type are applied to a specified member.

public static bool IsDefined<TAttribute>(this MemberInfo memberInfo) where TAttribute : Attribute

Parameters

memberInfo MemberInfo

Member to inspect.

Returns

bool

True if an attribute of the specified type is applied to element, otherwise false.

Type Parameters

TAttribute

The type of the attribute to search for.

IsDefined<TAttribute>(MemberInfo, bool)

Indicates whether custom attributes of a specified type are applied to a specified member, and optionally its ancestors.

public static bool IsDefined<TAttribute>(this MemberInfo memberInfo, bool inherit) where TAttribute : Attribute

Parameters

memberInfo MemberInfo

Member to inspect.

inherit bool

True to inspect the ancestors of element; otherwise, false.

Returns

bool

True if an attribute of the specified type is applied to element, otherwise false.

Type Parameters

TAttribute

The type of the attribute to search for.

SetValue(MemberInfo, object, object)

Sets the property or field value of a specified target object, accepts PropertyInfo or FieldInfo only.

public static void SetValue(this MemberInfo memberInfo, object target, object value)

Parameters

memberInfo MemberInfo

Member info object.

target object

Target object to set.

value object

Value to set.

Exceptions

ArgumentException

Member other that property or field is provided.