Version 3.3.0.1

MemberInfoExtensions class

Namespace: Sirenix.Utilities
Assembly: Sirenix.Utilities
public static class MemberInfoExtensions
MemberInfo method extensions.
Inheritance
  • System.Object
  • MemberInfoExtensions

Methods

DeAlias(MemberInfo, Boolean)
Returns the original, backing member of an alias member if the member is an alias.
public static MemberInfo DeAlias(this MemberInfo memberInfo, bool throwOnNotAliased = false)
Parameters
System.Reflection.MemberInfo memberInfo

The member to check.

System.Boolean throwOnNotAliased

if set to true an exception will be thrown if the member is not aliased.

Returns
System.Reflection.MemberInfo

Exceptions
System.ArgumentException

The member was not aliased; this only occurs if throwOnNotAliased is true.

GetAttribute<T>(ICustomAttributeProvider)
Returns the first found non-inherited custom attribute of type T on this member Returns null if none was found
public static T GetAttribute<T>(this ICustomAttributeProvider member)
    where T : Attribute
Parameters
System.Reflection.ICustomAttributeProvider member

Returns
T

Type Parameters
T

GetAttribute<T>(ICustomAttributeProvider, Boolean)
Returns the first found custom attribute of type T on this member Returns null if none was found
public static T GetAttribute<T>(this ICustomAttributeProvider member, bool inherit)
    where T : Attribute
Parameters
System.Reflection.ICustomAttributeProvider member

System.Boolean inherit

Returns
T

Type Parameters
T

GetAttributes(ICustomAttributeProvider)
Gets all attribute instances defined on a MemeberInfo.
public static Attribute[] GetAttributes(this ICustomAttributeProvider member)
Parameters
System.Reflection.ICustomAttributeProvider member

The member.

Returns
System.Attribute[]

GetAttributes(ICustomAttributeProvider, Boolean)
Gets all attribute instances on a MemberInfo.
public static Attribute[] GetAttributes(this ICustomAttributeProvider member, bool inherit)
Parameters
System.Reflection.ICustomAttributeProvider member

The member.

System.Boolean inherit

If true, specifies to also search the ancestors of element for custom attributes.

Returns
System.Attribute[]

GetAttributes<T>(ICustomAttributeProvider)
Gets all attributes of the specified generic type.
public static IEnumerable<T> GetAttributes<T>(this ICustomAttributeProvider member)
    where T : Attribute
Parameters
System.Reflection.ICustomAttributeProvider member

The member.

Returns
System.Collections.Generic.IEnumerable<T>

Type Parameters
T

GetAttributes<T>(ICustomAttributeProvider, Boolean)
Gets all attributes of the specified generic type.
public static IEnumerable<T> GetAttributes<T>(this ICustomAttributeProvider member, bool inherit)
    where T : Attribute
Parameters
System.Reflection.ICustomAttributeProvider member

The member.

System.Boolean inherit

If true, specifies to also search the ancestors of element for custom attributes.

Returns
System.Collections.Generic.IEnumerable<T>

Type Parameters
T

GetNiceName(MemberInfo)
If this member is a method, returns the full method name (name + params) otherwise the member name paskal splitted
public static string GetNiceName(this MemberInfo member)
Parameters
System.Reflection.MemberInfo member

Returns
System.String

IsAlias(MemberInfo)
Determines whether the specified member is an alias.
public static bool IsAlias(this MemberInfo memberInfo)
Parameters
System.Reflection.MemberInfo memberInfo

The member to check.

Returns
System.Boolean

true if the specified member is an alias; otherwise, false.

IsDefined<T>(ICustomAttributeProvider)
Returns true if the attribute whose type is specified by the generic argument is defined on this member
public static bool IsDefined<T>(this ICustomAttributeProvider member)
    where T : Attribute
Parameters
System.Reflection.ICustomAttributeProvider member

Returns
System.Boolean

Type Parameters
T

IsDefined<T>(ICustomAttributeProvider, Boolean)
Returns true if the attribute whose type is specified by the generic argument is defined on this member
public static bool IsDefined<T>(this ICustomAttributeProvider member, bool inherit)
    where T : Attribute
Parameters
System.Reflection.ICustomAttributeProvider member

System.Boolean inherit

Returns
System.Boolean

Type Parameters
T

IsStatic(MemberInfo)
Determines whether a FieldInfo, PropertyInfo or MethodInfo is static.
public static bool IsStatic(this MemberInfo member)
Parameters
System.Reflection.MemberInfo member

The member.

Returns
System.Boolean

true if the specified member is static; otherwise, false.

Exceptions
System.NotSupportedException

SignaturesAreEqual(MemberInfo, MemberInfo)
public static bool SignaturesAreEqual(this MemberInfo a, MemberInfo b)
Parameters
System.Reflection.MemberInfo a

System.Reflection.MemberInfo b

Returns
System.Boolean