Hi,
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.
Cheers.
***
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;
return
Interviewer == booking.Interviewer &&
StartDate == booking.StartDate &&
EndDate == booking.EndDate &&
Type == booking.Type;
}
return false;
}
public IAppointment Copy()
{
IAppointment appointment = new Booking();
appointment.CopyFrom(this);
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;
}
}