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
ParameterInfoParameter to retrieve an attribute from.
attributeType
TypeType of an Attribute to search for.
inherit
boolSpecifies 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
See GetCustomAttribute(ParameterInfo, Type, bool) for more information.
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
ParameterInfoParameter to retrieve attributes from.
attributeType
TypeType of an Attribute to search for.
inherit
boolSpecifies 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
See GetCustomAttributes(ParameterInfo, Type, bool) for more information.
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
ParameterInfoParameter to retrieve attributes from.
inherit
boolSpecifies 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
See GetCustomAttributes(ParameterInfo, Type, bool) for more information.
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
ParameterInfoParameter to retrieve an attribute from.
inherit
boolSpecifies 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
See GetCustomAttribute(ParameterInfo, Type, bool) for more information.
GetDebugString(ParameterInfo)
Creates a string representation of the provided parameter
.
[Pure]
public static string GetDebugString(this ParameterInfo parameter)
Parameters
parameter
ParameterInfoSource 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
ParameterInfoParameter to check.
attributeType
TypeType of an Attribute to search for.
inherit
boolSpecifies 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
ParameterInfoParameter to check.
inherit
boolSpecifies 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.