public static IDictionary <string, object> TurnObjectIntoDictionary(object data) { var attr = BindingFlags.Public | BindingFlags.Instance; var dict = new Dictionary <string, object>(); foreach (var prop in data.GetType().GetProperties(attr)) { if (prop.CanRead) { if (OnTypes.IsClass(prop.GetValue(data).GetType()) && !OnTypes.IsSimple(prop.GetValue(data).GetType())) { dict.Add(prop.Name, TurnObjectIntoDictionary(prop.GetValue(data))); } else { dict.Add(prop.Name, prop.GetValue(data, null)); } } } return(dict); }
public static bool IsClass(this Type type) { return(OnTypes.IsClass(type)); }