Class MemberInfoExtensions
Includes various extensions for the MemberInfo class.
Inherited Members
Namespace: TheXDS.MCART.Types.Extensions
Assembly: MCART.dll
Syntax
public static class MemberInfoExtensions
Methods
| Edit this page View SourceGetAttribute<T>(MemberInfo)
Returns the attribute associated with the declaration of the specified object.
Declaration
public static T? GetAttribute<T>(this MemberInfo member) where T : Attribute
Parameters
| Type | Name | Description |
|---|---|---|
| MemberInfo | member | The member from which to extract the attribute. |
Returns
| Type | Description |
|---|---|
| T | An attribute of the type |
Type Parameters
| Name | Description |
|---|---|
| T | Type of attribute to return. Must inherit Attribute. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
GetAttributes<T>(MemberInfo)
Returns the attribute associated with the assembly specified.
Declaration
public static IEnumerable<T> GetAttributes<T>(this MemberInfo member) where T : Attribute
Parameters
| Type | Name | Description |
|---|---|---|
| MemberInfo | member | MemberInfo from which to extract the attribute. |
Returns
| Type | Description |
|---|---|
| IEnumerable<T> | An attribute of the type |
Type Parameters
| Name | Description |
|---|---|
| T | Type of attribute to return. Must inherit Attribute. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
HasAttrValue<TAttribute, TValue>(MemberInfo, out TValue)
Determines if a member has a defined attribute.
Declaration
public static bool HasAttrValue<TAttribute, TValue>(this MemberInfo member, out TValue value) where TAttribute : Attribute, IValueAttribute<TValue>
Parameters
| Type | Name | Description |
|---|---|---|
| MemberInfo | member | The member from which to extract the attribute. |
| TValue | value | Output parameter. If an attribute of type |
Returns
| Type | Description |
|---|---|
| bool |
Type Parameters
| Name | Description |
|---|---|
| TAttribute | Type of attribute to return. Must inherit from Attribute and from IValueAttribute<T> |
| TValue | Type of value to return. |
HasAttribute<T>(MemberInfo)
Determines if a member has a defined attribute.
Declaration
public static bool HasAttribute<T>(this MemberInfo member) where T : Attribute
Parameters
| Type | Name | Description |
|---|---|---|
| MemberInfo | member | The member from which to extract the attribute. |
Returns
| Type | Description |
|---|---|
| bool |
Type Parameters
| Name | Description |
|---|---|
| T | Type of attribute to return. Must inherit Attribute. |
HasAttribute<T>(MemberInfo, out T?)
Determines if a member has a defined attribute.
Declaration
public static bool HasAttribute<T>(this MemberInfo member, out T? attribute) where T : notnull, Attribute
Parameters
| Type | Name | Description |
|---|---|---|
| MemberInfo | member | The member from which to extract the attribute. |
| T | attribute | Output parameter. If an attribute of type |
Returns
| Type | Description |
|---|---|
| bool |
Type Parameters
| Name | Description |
|---|---|
| T | Type of attribute to return. Must inherit Attribute. |
HasAttributes<T>(MemberInfo, out IEnumerable<T>)
Determines if a member has a defined attribute.
Declaration
public static bool HasAttributes<T>(this MemberInfo member, out IEnumerable<T> attribute) where T : Attribute
Parameters
| Type | Name | Description |
|---|---|---|
| MemberInfo | member | The member from which to extract the attribute. |
| IEnumerable<T> | attribute | Output parameter. If an attribute of type |
Returns
| Type | Description |
|---|---|
| bool |
Type Parameters
| Name | Description |
|---|---|
| T | Type of attribute to return. Must inherit Attribute. |
NameOf(MemberInfo)
Gets a friendly name for a member.
Declaration
public static string NameOf(this MemberInfo member)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberInfo | member | The MemberInfo from which to get the name. |
Returns
| Type | Description |
|---|---|
| string | A friendly name for |