public static Type[] GetObjectInterfaces(this object obj)
 {
     if (DispatchUtility.ImplementsIDispatch(obj))
     {
         return(DispatchUtility.GetType(obj, false)?.GetInterfaces());
     }
     return(obj?.GetType().GetInterfaces());
 }
        public static string[] GetObjectMethods(this object obj)
        {
            Type type = obj?.GetType();

            if (DispatchUtility.ImplementsIDispatch(obj))
            {
                type = DispatchUtility.GetType(obj, false);
            }

            return(type?.GetMethods().Select(m =>
            {
                string parameters = string.Join(", ", m.GetParameters().Select(p => p.ParameterType.Name));
                return $"{m.DeclaringType.Name}.{m.Name}({parameters})";
            }).ToArray());
        }
        public static string[] GetObjectProperties(this object obj)
        {
            Type type = obj?.GetType();

            if (DispatchUtility.ImplementsIDispatch(obj))
            {
                type = DispatchUtility.GetType(obj, false);
            }

            return(type?.GetProperties().Select(p =>
            {
                string name = p.Name;
                string value = null;
                try
                {
                    value = p.GetValue(obj)?.ToString() ?? "NULL";
                }
                catch (Exception ex)
                {
                    value = $"ERROR: {ex.Message}";
                }
                return $"{p.DeclaringType.Name}.{name}: {value}";
            }).ToArray() ?? Array.Empty <string>());
        }