Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Cloning and Inheritance (Read 2498 times)
Damian
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Joined: Apr 26th, 2006
Cloning and Inheritance
Jul 4th, 2006 at 9:23pm
Print Post  
Ive inherited the Appointment class in my own class and want to create duplicate items from an already added appointment for several contacts using the same information but not sure best way to do this.

Do I override the clone in my inherited class and clone the appointment (base.Clone()) then create my new custom object and set the properties of my new custom object to the cloned appointment??

Still relatively new to .net so sorry if im totally wrong here.
???
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Cloning and Inheritance
Reply #1 - Jul 5th, 2006 at 4:40am
Print Post  
Here is the implementation of the Appointment.Clone method. You have to do something similar in your derived class, adding your custom properties as well. You do not have to call the base's Clone, since it would create a new object of the base class and you won't really need it.

Code
Select All
public override object Clone()
{
  Appointment clone = new Appointment();

  clone.AllDayEvent = this.AllDayEvent;
  clone.DescriptionText = this.DescriptionText;
  clone.EndTime = this.EndTime;
  clone.HeaderText = this.HeaderText;
  clone.ImageIndex = this.ImageIndex;
  clone.Location = this.Location;
  clone.Locked = this.Locked;
  clone.Priority = this.Priority;
  clone.Reminder = this.Reminder;
  clone.SelectedStyle = this.Style;
  clone.StartTime = this.StartTime;
  clone.Style = this.Style;
  clone.Tag = this.Tag;
  clone.Task = this.Task;
  clone.Visible = this.Visible;

  foreach (Resource resource in this.Resources)
    clone.Resources.Add(resource);

  foreach (Contact contact in this.Contacts)
    clone.Contacts.Add(contact);

  return clone;
} 



Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint