mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-17 07:44:09 +02:00
Added HasCustomAttribute to MethodInfo/FieldInfo
This commit is contained in:
parent
da29789bd6
commit
bbd0fe8779
2 changed files with 36 additions and 0 deletions
|
@ -133,6 +133,24 @@ namespace System.Reflection
|
|||
return mTypeInstance.[Friend]GetCustomAttributes<T>(mData.mMethodData.mParamData[paramIdx].mCustomAttributesIdx);
|
||||
}
|
||||
|
||||
public bool HasCustomAttribute<T>() where T : Attribute
|
||||
{
|
||||
if (Compiler.IsComptime)
|
||||
{
|
||||
int32 attrIdx = -1;
|
||||
Type attrType = null;
|
||||
repeat
|
||||
{
|
||||
attrType = Type.[Friend]Comptime_Method_GetCustomAttributeType(mData.mComptimeMethodInstance, ++attrIdx);
|
||||
if (attrType == typeof(T))
|
||||
return true;
|
||||
}
|
||||
while (attrType != null);
|
||||
return false;
|
||||
}
|
||||
return mTypeInstance.[Friend]HasCustomAttribute<T>(mData.mMethodData.mCustomAttributesIdx);
|
||||
}
|
||||
|
||||
public Result<T> GetCustomAttribute<T>() where T : Attribute
|
||||
{
|
||||
if (Compiler.IsComptime)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue