/* * SPDX-License-Identifier: AGPL-3.0-or-later * Copyright (C) 2025 Sergej Görzen * This file is part of xAPI4Unity. */ #if UNITY_EDITOR using System; namespace xAPI4Unity.Editor.Parser { /// /// Access modifiers /// internal enum Modifier { Public, Private, Protected, Static, Virtual, ReadOnly, Sealed } /// /// Class with enum methods /// internal static class EnumMethods { /// /// Gets the string of a source key /// /// Source type /// String of a source type public static string GetSourceKeyString(this SourceType type) { return type.GetName(); } /// /// Gets a source type from a string /// /// Source type string /// Corresponding source type public static SourceType? GetSourceKeyFromString(this string str) { foreach (SourceType val in Enum.GetValues(typeof(SourceType))) { if (val.GetName() == str || val.GetSourceKeyString() == str) { return val; } } return null; } /// /// Gets the name of an enum /// /// Enum value /// Name of the enum value public static string GetName(this Enum enu) { return Enum.GetName(enu.GetType(), enu); } } } #endif