Class fsPortableReflection
This wraps reflection types so that it is portable across different Unity
runtimes.
Inheritance
fsPortableReflection
Syntax
public static class fsPortableReflection
Fields
EmptyTypes
Declaration
public static Type[] EmptyTypes
Field Value
Methods
AsMemberInfo(Type)
Declaration
public static MemberInfo AsMemberInfo(Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
AsType(MemberInfo)
Declaration
public static Type AsType(MemberInfo member)
Parameters
Returns
GetAttribute(MemberInfo, Type, Boolean)
Fetches the given attribute from the given MemberInfo. This method
applies caching and is allocation free (after caching has been
performed).
Declaration
public static Attribute GetAttribute(MemberInfo element, Type attributeType, bool shouldCache)
Parameters
Type |
Name |
Description |
MemberInfo |
element |
The MemberInfo the get the attribute from.
|
Type |
attributeType |
The type of attribute to fetch.
|
Boolean |
shouldCache |
|
Returns
Type |
Description |
Attribute |
The attribute or null.
|
GetAttribute<TAttribute>(MemberInfo)
Declaration
public static TAttribute GetAttribute<TAttribute>(MemberInfo element)
where TAttribute : Attribute
Parameters
Returns
Type |
Description |
TAttribute |
|
Type Parameters
Name |
Description |
TAttribute |
|
GetAttribute<TAttribute>(MemberInfo, Boolean)
Fetches the given attribute from the given MemberInfo.
Declaration
public static TAttribute GetAttribute<TAttribute>(MemberInfo element, bool shouldCache)
where TAttribute : Attribute
Parameters
Type |
Name |
Description |
MemberInfo |
element |
The MemberInfo to get the attribute from.
|
Boolean |
shouldCache |
Should this computation be cached? If this is the only time it will
ever be done, don't bother caching.
|
Returns
Type |
Description |
TAttribute |
The attribute or null.
|
Type Parameters
Name |
Description |
TAttribute |
The type of attribute to fetch.
|
GetDeclaredConstructor(Type, Type[])
Declaration
public static ConstructorInfo GetDeclaredConstructor(this Type type, Type[] parameters)
Parameters
Type |
Name |
Description |
Type |
type |
|
Type[] |
parameters |
|
Returns
GetDeclaredConstructors(Type)
Declaration
public static ConstructorInfo[] GetDeclaredConstructors(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
GetDeclaredFields(Type)
Declaration
public static FieldInfo[] GetDeclaredFields(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
GetDeclaredMember(Type, String)
Declaration
public static MemberInfo GetDeclaredMember(this Type type, string memberName)
Parameters
Returns
GetDeclaredMembers(Type)
Declaration
public static MemberInfo[] GetDeclaredMembers(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
GetDeclaredMethod(Type, String)
Declaration
public static MethodInfo GetDeclaredMethod(this Type type, string methodName)
Parameters
Returns
GetDeclaredMethods(Type)
Declaration
public static MethodInfo[] GetDeclaredMethods(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
GetDeclaredProperties(Type)
Declaration
public static PropertyInfo[] GetDeclaredProperties(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
GetDeclaredProperty(Type, String)
Declaration
public static PropertyInfo GetDeclaredProperty(this Type type, string propertyName)
Parameters
Type |
Name |
Description |
Type |
type |
|
String |
propertyName |
|
Returns
GetFlattenedMember(Type, String)
Declaration
public static MemberInfo[] GetFlattenedMember(this Type type, string memberName)
Parameters
Returns
GetFlattenedMethod(Type, String)
Declaration
public static MethodInfo GetFlattenedMethod(this Type type, string methodName)
Parameters
Returns
GetFlattenedMethods(Type, String)
Declaration
public static IEnumerable<MethodInfo> GetFlattenedMethods(this Type type, string methodName)
Parameters
Returns
GetFlattenedProperty(Type, String)
Declaration
public static PropertyInfo GetFlattenedProperty(this Type type, string propertyName)
Parameters
Type |
Name |
Description |
Type |
type |
|
String |
propertyName |
|
Returns
HasAttribute(MemberInfo, Type)
Returns true if the given attribute is defined on the given element.
Declaration
public static bool HasAttribute(MemberInfo element, Type attributeType)
Parameters
Returns
HasAttribute(MemberInfo, Type, Boolean)
Returns true if the given attribute is defined on the given element.
Declaration
public static bool HasAttribute(MemberInfo element, Type attributeType, bool shouldCache)
Parameters
Returns
HasAttribute<TAttribute>(MemberInfo)
Returns true if the given attribute is defined on the given element.
Declaration
public static bool HasAttribute<TAttribute>(MemberInfo element)
Parameters
Returns
Type Parameters
Name |
Description |
TAttribute |
|
HasAttribute<TAttribute>(MemberInfo, Boolean)
Returns true if the given attribute is defined on the given element.
Declaration
public static bool HasAttribute<TAttribute>(MemberInfo element, bool shouldCache)
Parameters
Returns
Type Parameters
Name |
Description |
TAttribute |
|
IsType(MemberInfo)
Declaration
public static bool IsType(MemberInfo member)
Parameters
Returns
Resolve(Type)
Declaration
public static Type Resolve(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.