IAppoinment implementation

2 posts, 0 answers
  1. Steven
    Steven avatar
    10 posts
    Member since:
    Apr 2011

    Posted 24 Apr 2012 Link to this post


    I'm having a few difficulties getting the ScheduleView to work properly when my appointment class implements IAppoinment. I don't really want to inherit from AppoinmentBase because my appointment object already inherits from another class (its basically a DTO returned from a WCF service), which is why I've opted to implement the IAppointment interface instead (implemented in a partial class).

    With all the examples I find, the appoinment class inherits from AppointmentBase. I CAN get things to work when I wrap my DTO in a AppointmentBase subclass (i.e. AppoinmentWrapper), but I dont really like this abstraction - I'd rather just implement IAppoinment.

    Basically, Im getting a ManagedRuntimeError which is a null reference exception. I suspect I'm not implementing something correctly in my IAppointment implementation, which is below.

    Any ideas as to why this may be happening.



        public partial class Booking : IAppointment
            public Booking()
                IsAllDayEvent = false;
                RecurrenceRule = new RecurrenceRule(new RecurrencePattern());
                Resources = new ResourceCollection();
                TimeZone = TimeZoneInfo.Utc;
                Subject = "somethign";

            public DateTime End
                get { return !EndDate.HasValue ? DateTime.MinValue : EndDate.Value; }
                set { EndDate = value; }

            public bool IsAllDayEvent { get; set; }

            public IRecurrenceRule RecurrenceRule { get; set; }

            public event EventHandler RecurrenceRuleChanged;

            public IList Resources { get; private set; }

            public DateTime Start
                get { return !StartDate.HasValue ? DateTime.MinValue : StartDate.Value; }
                set { StartDate = value; }

            public string Subject { get; set; }

            public TimeZoneInfo TimeZone { get; set; }

            public void BeginEdit()
                throw new NotImplementedException();

            public void CancelEdit()
                throw new NotImplementedException();

            public void EndEdit()
                throw new NotImplementedException();

            public bool Equals(IAppointment other)
                if (other is Booking)
                    var booking = other as Booking;

                        Interviewer == booking.Interviewer &&
                        StartDate == booking.StartDate &&
                        EndDate == booking.EndDate &&
                        Type == booking.Type;

                return false;

            public IAppointment Copy()
                IAppointment appointment = new Booking();

                return appointment;

            public void CopyFrom(IAppointment other)
                var appointment = other as Booking;
                if (appointment == null) return;

                EndDate = appointment.EndDate;
                Interviewer = appointment.Interviewer;
                Lead = appointment.Lead;
                Office = appointment.Office;
                Result = appointment.Result;
                ResultDate = appointment.ResultDate;
                ResultUser = appointment.ResultUser;
                StartDate = appointment.StartDate;
                Type = appointment.Type;

  2. George
    George avatar
    1332 posts

    Posted 26 Apr 2012 Link to this post

    Hello Steven,

    I am not sure what could cause the null reference exception, but I would suggest referring to the following:
    In this example the WPF RIA services are used and the entities implement the IAppointment interface (the scenario is very similar to the given one). You could refer to it and see how the interfaces are implemented - it could shed some light on the problem. 

    Hope this helps. Please do not hesitate to contact us if you have any additional questions.

    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top