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
parameterParameterInfoParameter to retrieve an attribute from.
attributeTypeTypeType of an Attribute to search for.
inheritboolSpecifies 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
parameterParameterInfoParameter to retrieve attributes from.
attributeTypeTypeType of an Attribute to search for.
inheritboolSpecifies 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
parameterParameterInfoParameter to retrieve attributes from.
inheritboolSpecifies 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
TType 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
parameterParameterInfoParameter to retrieve an attribute from.
inheritboolSpecifies 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
TType 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
parameterParameterInfoSource 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
parameterParameterInfoParameter to check.
attributeTypeTypeType of an Attribute to search for.
inheritboolSpecifies 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
parameterParameterInfoParameter to check.
inheritboolSpecifies 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
TType of an Attribute to search for.
Remarks
See IsDefined(ParameterInfo, Type, bool) for more information.