mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-26 03:28:02 +02:00
Variant TryGet
This commit is contained in:
parent
0990537b7e
commit
c58f327136
1 changed files with 11 additions and 0 deletions
|
@ -65,6 +65,8 @@ namespace System
|
||||||
}
|
}
|
||||||
if (mStructType <= 1)
|
if (mStructType <= 1)
|
||||||
{
|
{
|
||||||
|
if (mData == 0)
|
||||||
|
return null;
|
||||||
return Internal.UnsafeCastToObject((void*)mData).GetType();
|
return Internal.UnsafeCastToObject((void*)mData).GetType();
|
||||||
}
|
}
|
||||||
return (Type)Internal.UnsafeCastToObject((void*)(mStructType & ~3));
|
return (Type)Internal.UnsafeCastToObject((void*)(mStructType & ~3));
|
||||||
|
@ -343,6 +345,15 @@ namespace System
|
||||||
return *(T*)(void*)mData;
|
return *(T*)(void*)mData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TryGet<T>(out T value)
|
||||||
|
{
|
||||||
|
value = default;
|
||||||
|
if (VariantType != typeof(T))
|
||||||
|
return false;
|
||||||
|
value = Get<T>();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public Result<Object> GetBoxed()
|
public Result<Object> GetBoxed()
|
||||||
{
|
{
|
||||||
if (IsObject)
|
if (IsObject)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue