//////////////////////////////////////////////////////////////// // // InspectList.q // //////////////////////////////////////////////////////////////// (Export InspectList) (Def (InspectList f OPTIONAL astype) (Local name value block method answer) (Cond ((IsNull astype) (Setq astype (GetType f))) ((IsSymbol astype) (Setq astype (Eval astype)))) (TypeCheck astype Type) (Setq answer []) (ForEach (field (Type.GetFields astype)) (When (And (Is field FieldInfo) (Or (Is field RuntimeFieldInfo) (FieldInfo.IsPublic field)) (Not (FieldInfo.IsStatic field))) (Setq name field.Name) (Setq value (astype.InvokeMember field.Name BindingFlags.GetField NULL f [])) (Push answer [name value]))) (ForEach (property (Type.GetProperties astype)) (When (Is property PropertyInfo) // NOTE: Some properties, e.g. String.Chars, take parameters. // We don't want those. (Setq method (GetGetMethod property)) (When (And (<<>> method NULL) (MethodInfo.IsPublic method) (Not (MethodInfo.IsStatic method)) (IsZero (Length (GetParameters method)))) (Setq name property.Name) (Setq value (astype.InvokeMember property.Name BindingFlags.GetProperty NULL f [])) (Push answer [name value])))) (Setq answer (Sort answer)) (Setq answer (Append [["Object" f]["Type" (GetType f)]] answer)) (Return answer) )