Getting the Appointment Id from the DevExpress Scheduler

I recently had a problem with the DevExpress scheduler where I needed to get the appointment Id to manipulate my application's own business objects. For some reason the guys at DevExpress have the Id as a private member variable which should make this impossible.

However with the reflection capabilities of .net nothing can be really hidden, so I ended up writing some pretty horrible code to get the Id but I think it was the only way to solve my problem:

Appointment apt = Control.SelectedAppointments[0];FieldInfo fld = typeof(Appointment).GetField("id", BindingFlags.Instance | BindingFlags.NonPublic);int appointmentId = int.Parse(fld.GetValue(apt).ToString());
 
I put this in my custom appointment handler class:
 
public class CustomMenuAppointmentCallbackCommand : SchedulerCallbackCommand    {        string menuItemId = String.Empty;        public CustomMenuAppointmentCallbackCommand(ASPxScheduler control)            : base(control)        {        }        public override string Id { get { return "USRAPTMENU"; } }        public string MenuItemId { get { return menuItemId; } }        protected override void ParseParameters(string parameters)        {            this.menuItemId = parameters;        }        protected override void ExecuteCore()        {            Appointment apt = Control.SelectedAppointments[0];            FieldInfo fld = typeof(Appointment).GetField("id", BindingFlags.Instance | BindingFlags.NonPublic);            int appointmentId = int.Parse(fld.GetValue(apt).ToString());            //more code using the appointment id         }}
 
That's it!