Table of Contents

Class ParameterInfoExtensions

Namespace
LfrlAnvil.Extensions
Assembly
LfrlAnvil.Core.dll

Contains ParameterInfo extension methods.

public static class ParameterInfoExtensions
Inheritance
ParameterInfoExtensions
Inherited Members

Methods

GetAttribute(ParameterInfo, Type, bool)

Attempts to retrieve an attribute of the specified type from the given parameter.

[Pure]
public static Attribute? GetAttribute(this ParameterInfo parameter, Type attributeType, bool inherit = true)

Parameters

parameter ParameterInfo

Parameter to retrieve an attribute from.

attributeType Type

Type of an Attribute to search for.

inherit bool

Specifies whether or not to include parameter's ancestors in the search. Equal to true by default.

Returns

Attribute

Found attribute's instance or null, if it does not exist.

Remarks

GetAttributeRange(ParameterInfo, Type, bool)

Attempts to retrieve all attributes of the specified type from the given parameter.

[Pure]
public static Attribute[] GetAttributeRange(this ParameterInfo parameter, Type attributeType, bool inherit = true)

Parameters

parameter ParameterInfo

Parameter to retrieve attributes from.

attributeType Type

Type of an Attribute to search for.

inherit bool

Specifies whether or not to include parameter's ancestors in the search. Equal to true by default.

Returns

Attribute[]

All found attribute's instances or an empty array, if it does not exist.

Remarks

GetAttributeRange<T>(ParameterInfo, bool)

Attempts to retrieve all attributes of the specified type from the given parameter.

[Pure]
public static IEnumerable<T> GetAttributeRange<T>(this ParameterInfo parameter, bool inherit = true) where T : Attribute

Parameters

parameter ParameterInfo

Parameter to retrieve attributes from.

inherit bool

Specifies whether or not to include parameter's ancestors in the search. Equal to true by default.

Returns

IEnumerable<T>

All found attribute's instances or an empty array, if it does not exist.

Type Parameters

T

Type of an Attribute to search for.

Remarks

GetAttribute<T>(ParameterInfo, bool)

Attempts to retrieve an attribute of the specified type from the given parameter.

[Pure]
public static T? GetAttribute<T>(this ParameterInfo parameter, bool inherit = true) where T : Attribute

Parameters

parameter ParameterInfo

Parameter to retrieve an attribute from.

inherit bool

Specifies whether or not to include parameter's ancestors in the search. Equal to true by default.

Returns

T

Found attribute's instance or null, if it does not exist.

Type Parameters

T

Type of an Attribute to search for.

Remarks

GetDebugString(ParameterInfo)

Creates a string representation of the provided parameter.

[Pure]
public static string GetDebugString(this ParameterInfo parameter)

Parameters

parameter ParameterInfo

Source parameter info.

Returns

string

String representation of the provided parameter.

HasAttribute(ParameterInfo, Type, bool)

Checks if an attribute of the specified type exists for the given parameter.

[Pure]
public static bool HasAttribute(this ParameterInfo parameter, Type attributeType, bool inherit = true)

Parameters

parameter ParameterInfo

Parameter to check.

attributeType Type

Type of an Attribute to search for.

inherit bool

Specifies whether or not to include parameter's ancestors in the search. Equal to true by default.

Returns

bool

true when an attribute of the specified type exists for the given parameter, otherwise false.

Remarks

See IsDefined(ParameterInfo, Type, bool) for more information.

HasAttribute<T>(ParameterInfo, bool)

Checks if an attribute of the specified type exists for the given parameter.

[Pure]
public static bool HasAttribute<T>(this ParameterInfo parameter, bool inherit = true) where T : Attribute

Parameters

parameter ParameterInfo

Parameter to check.

inherit bool

Specifies whether or not to include parameter's ancestors in the search. Equal to true by default.

Returns

bool

true when an attribute of the specified type exists for the given parameter, otherwise false.

Type Parameters

T

Type of an Attribute to search for.

Remarks

See IsDefined(ParameterInfo, Type, bool) for more information.