init commit

This commit is contained in:
2025-10-09 09:57:24 +09:00
commit 4d551bd74f
6636 changed files with 1218703 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
using System;
using Org.BouncyCastle.Utilities.Date;
namespace Org.BouncyCastle.Utilities;
internal abstract class Enums
{
internal static Enum GetEnumValue(Type enumType, string s)
{
if (!IsEnumType(enumType))
{
throw new ArgumentException("Not an enumeration type", "enumType");
}
if (s.Length > 0 && char.IsLetter(s[0]) && s.IndexOf(',') < 0)
{
s = s.Replace('-', '_');
s = s.Replace('/', '_');
return (Enum)Enum.Parse(enumType, s, ignoreCase: false);
}
throw new ArgumentException();
}
internal static Array GetEnumValues(Type enumType)
{
if (!IsEnumType(enumType))
{
throw new ArgumentException("Not an enumeration type", "enumType");
}
return Enum.GetValues(enumType);
}
internal static Enum GetArbitraryValue(Type enumType)
{
Array enumValues = GetEnumValues(enumType);
int index = (int)(DateTimeUtilities.CurrentUnixMs() & 0x7FFFFFFF) % enumValues.Length;
return (Enum)enumValues.GetValue(index);
}
internal static bool IsEnumType(Type t)
{
return t.IsEnum;
}
}