#region Namespaces
 
using System;
using System.Text;
using System.Linq;
using System.Xml;
using System.Reflection;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Forms;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Windows;
using AcadApplication = Autodesk.AutoCAD.ApplicationServices.Application;
using AcadDocument = Autodesk.AutoCAD.ApplicationServices.Document;
using AcadWindows = Autodesk.AutoCAD.Windows;
 
#endregion
 
namespace AcadNetAddinWizard_Namespace
{
 
    public class TestCommands
    {
        Database db = HostApplicationServices.WorkingDatabase;
        Editor ed = AcadApplication.DocumentManager.MdiActiveDocument.Editor;
        void Dump(DBObject obj)
        {
            string msg = string.Format("Properties of the {0} with handle {1}:\n", obj.GetType().Name, obj.Handle);
 
            PropertyInfo[] piArr = obj.GetType().GetProperties();
            foreach (PropertyInfo pi in piArr)
            {
                object value = null;
                try
                {
                    value = pi.GetValue(obj, null);
                }
                catch (System.Exception ex)
                {
                    if (ex.InnerException is Autodesk.AutoCAD.Runtime.Exception &&
                        (ex.InnerException as Autodesk.AutoCAD.Runtime.Exception).ErrorStatus == ErrorStatus.NotApplicable)
                        continue;
                    else
                        throw;
                }
 
                msg += string.Format("\t{0}: {1}\n", pi.Name, value);
            }
 
            ed.WriteMessage("\n" + msg);
            MessageBox.Show(msg, "DBObject/Entity Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
     
 
        [CommandMethod("DumpEntityInfo")]
        public void DumpEntityInfo_Method()
        {
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                //TODO: add your code below.    
                Debug.WriteLine("DumpEntityInfo ran.");
                ed.WriteMessage("DumpEntityInfo ran.\n");
 
                PromptEntityResult selRes = ed.GetEntity("Pick an entity:");
                if (selRes.Status == PromptStatus.OK)
                {
                    Entity ent = tr.GetObject(selRes.ObjectId, OpenMode.ForRead) as Entity;
                    Dump(ent);
                }
 
                tr.Commit();
            }
        }
 
    }
}