using System; using System.Collections.Generic; internal static class BriskValueReader { public static string GetString(Dictionary data, string key) { if (!TryGetValue(data, key, out var value) || value == null) { return null; } return Convert.ToString(value); } public static bool GetBool(Dictionary data, string key) { if (!TryGetValue(data, key, out var value) || value == null) { return false; } if (value is bool boolValue) { return boolValue; } if (bool.TryParse(Convert.ToString(value), out var parsed)) { return parsed; } return false; } public static int GetInt(Dictionary data, string key) { if (!TryGetValue(data, key, out var value) || value == null) { return 0; } try { return Convert.ToInt32(value); } catch { return 0; } } public static long GetLong(Dictionary data, string key) { if (!TryGetValue(data, key, out var value) || value == null) { return 0L; } try { return Convert.ToInt64(value); } catch { return 0L; } } public static Dictionary GetDictionary(Dictionary data, string key) { if (!TryGetValue(data, key, out var value) || value == null) { return null; } return value as Dictionary; } public static List GetList(Dictionary data, string key) { if (!TryGetValue(data, key, out var value) || value == null) { return null; } return value as List; } public static bool TryGetValue(Dictionary data, string key, out object value) { value = null; return data != null && !string.IsNullOrWhiteSpace(key) && data.TryGetValue(key, out value); } }