mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-22 01:37:59 +02:00
Added GetEnumerator
This commit is contained in:
parent
c5e1e70409
commit
b2cb8f74d3
1 changed files with 28 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
namespace System
|
namespace System
|
||||||
{
|
{
|
||||||
|
@ -43,13 +44,19 @@ namespace System
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly EnumValuesEnumerator<TEnum> GetValues<TEnum>()
|
public static EnumEnumerator<TEnum> GetEnumerator<TEnum>()
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
return .();
|
return .();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly EnumNamesEnumerator<TEnum> GetNames<TEnum>()
|
public static EnumValuesEnumerator<TEnum> GetValues<TEnum>()
|
||||||
|
where TEnum : enum
|
||||||
|
{
|
||||||
|
return .();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumNamesEnumerator<TEnum> GetNames<TEnum>()
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
return .();
|
return .();
|
||||||
|
@ -120,6 +127,25 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct EnumEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<(StringView name, TEnum value)>
|
||||||
|
where TEnum : enum
|
||||||
|
{
|
||||||
|
public new (StringView name, TEnum value) Current
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ((.)base.Current.[Friend]mFieldData.[Friend]mName, (.)base.Current.[Friend]mFieldData.[Friend]mData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public new Result<(StringView name, TEnum value)> GetNext() mut
|
||||||
|
{
|
||||||
|
if (!MoveNext())
|
||||||
|
return .Err;
|
||||||
|
return Current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public struct EnumValuesEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<TEnum>
|
public struct EnumValuesEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<TEnum>
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue