MemberInfoExtensions¶
Namespace:
SideXP.Core.Reflection
Extension functions for MemberInfo instances.
Methods¶
IsExposed(MemberInfo)¶
Checks if a given member (field or property) is exposed (public or private serialized).
Parameters
member: The member to check.
Returns
Returns true if the given member is exposed.
IsPublic(MemberInfo)¶
Checks if a given member (field or property) is public.
Parameters
member: The member to check.
Returns
Returns true if the given member is public.
Remarks
A property is considered public if one of its accessors is marked as public.
IsPrivate(MemberInfo)¶
Checks if a given member (field or property) is private.
Parameters
member: The member to check.
Returns
Returns true if the given member is private.
Remarks
A property is considered private if its accessors are both marked as private.
TryGetAttribute(MemberInfo, Type, Attribute, bool)¶
public static bool TryGetAttribute(MemberInfo member, Type attributeType, out Attribute attribute, bool inherit = true)
Tries to get an attribute of a given type defined on a given member.
Parameters
member: The member from which to get the attribute.attributeType: The type of the attribute to get. Assumes it inherits fromAttribute, and the member only uses it once.attribute: Outputs the found attribute.inherit: If enabled, the ancestors of the given member are also checked.
Returns
Returns true if the custom attribute has been found.
TryGetAttribute<TAttribute>(MemberInfo, TAttribute, bool)¶
public static bool TryGetAttribute<TAttribute>(MemberInfo member, out TAttribute attribute, bool inherit = true)
Type parameters
TAttribute
TryGetAttributes(MemberInfo, Type, Attribute[], bool)¶
public static bool TryGetAttributes(MemberInfo member, Type attributeType, out Attribute[] attributes, bool inherit = true)
Tries to get the attributes of a given type defined on a given member.
Parameters
member: The member from which to get the attributes.attributeType: The type of the attributes to get.attributes: Outputs the found attributes.inherit: If enabled, the ancestors of the given member are also checked.
Returns
Returns true if at least one attribute of the given type has been found.
TryGetAttributes<TAttribute>(MemberInfo, TAttribute[], bool)¶
public static bool TryGetAttributes<TAttribute>(MemberInfo member, out TAttribute[] attributes, bool inherit = true)
Type parameters
TAttribute