namespace GmRelay.Shared.Domain; public enum SessionNotificationMode { GroupAndDirect, GroupOnly } public static class SessionNotificationModeExtensions { public const string GroupAndDirectValue = nameof(SessionNotificationMode.GroupAndDirect); public const string GroupOnlyValue = nameof(SessionNotificationMode.GroupOnly); public static bool ShouldSendDirectMessages(this SessionNotificationMode mode) => mode == SessionNotificationMode.GroupAndDirect; public static string ToDatabaseValue(this SessionNotificationMode mode) => mode switch { SessionNotificationMode.GroupAndDirect => GroupAndDirectValue, SessionNotificationMode.GroupOnly => GroupOnlyValue, _ => throw new ArgumentOutOfRangeException(nameof(mode), mode, "Unknown notification mode.") }; public static SessionNotificationMode FromDatabaseValue(string? value) => value switch { null or "" => SessionNotificationMode.GroupAndDirect, GroupAndDirectValue => SessionNotificationMode.GroupAndDirect, GroupOnlyValue => SessionNotificationMode.GroupOnly, _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown notification mode.") }; }