using System; using System.Collections.Generic; using Unity.UIWidgets.foundation; namespace ChatComponents { public static class ChatRoomUtils { public static Status? getStatusFromString(string stringStatus) { foreach( var status in Enum.GetValues(typeof(Status))) { if (status.ToString() == stringStatus) { return status is Status ? (Status) status : (Status?) null; } } return null; } /// Converts [stringRole] to the [Role] enum. public static Role? getRoleFromString(string stringRole) { foreach( var role in Enum.GetValues(typeof(Role))) { if (role.ToString() == stringRole) { return role is Role ? (Role) role : (Role?) null; } } return null; } /// Converts [stringRoomType] to the [RoomType] enum. public static RoomType getRoomTypeFromString(string stringRoomType) { foreach( var roomType in Enum.GetValues(typeof(RoomType))) { if (roomType.ToString() == stringRoomType) { return (RoomType) (roomType is RoomType ? (RoomType) roomType : (RoomType?) null); } } return RoomType.unsupported; } public static string toShortString(object _object = null) { return _object.ToString().Split('.').last(); } } }