mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-17 15:46:05 +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
|
@ -230,6 +230,24 @@ namespace System.Reflection
|
||||||
*((*(T2**)&data)++)
|
*((*(T2**)&data)++)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasCustomAttribute<T>() where T : Attribute
|
||||||
|
{
|
||||||
|
if (Compiler.IsComptime)
|
||||||
|
{
|
||||||
|
int32 attrIdx = -1;
|
||||||
|
Type attrType = null;
|
||||||
|
repeat
|
||||||
|
{
|
||||||
|
attrType = Type.[Friend]Comptime_Field_GetCustomAttributeType((int32)mTypeInstance.TypeId, mFieldData.mCustomAttributesIdx, ++attrIdx);
|
||||||
|
if (attrType == typeof(T))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
while (attrType != null);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return mTypeInstance.[Friend]HasCustomAttribute<T>(mFieldData.mCustomAttributesIdx);
|
||||||
|
}
|
||||||
|
|
||||||
public Result<T> GetCustomAttribute<T>() where T : Attribute
|
public Result<T> GetCustomAttribute<T>() where T : Attribute
|
||||||
{
|
{
|
||||||
if (Compiler.IsComptime)
|
if (Compiler.IsComptime)
|
||||||
|
|
|
@ -133,6 +133,24 @@ namespace System.Reflection
|
||||||
return mTypeInstance.[Friend]GetCustomAttributes<T>(mData.mMethodData.mParamData[paramIdx].mCustomAttributesIdx);
|
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
|
public Result<T> GetCustomAttribute<T>() where T : Attribute
|
||||||
{
|
{
|
||||||
if (Compiler.IsComptime)
|
if (Compiler.IsComptime)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue