S
Steve
I can't find a straight answer on what to use? I need a deep copy, so I
implemented IConeable and the Clone() method. However, I'm not sure I did
it correct. Is it suposed to be an allocation of a new object, then the
assignment of each member? Is that all or is there something else I need to
do?
Here is my code
<code>
public Object Clone()
{
BOLDeviceProtocol newObject = new BOLDeviceProtocol();
newObject.m_custom = this.m_custom;
newObject.m_dal = this.m_dal;
newObject.m_deviceProtocolID = this.m_deviceProtocolID;
newObject.m_deviceSettingsID = this.m_deviceSettingsID;
newObject.m_duration = this.m_duration;
newObject.m_enabled = this.m_enabled;
newObject.m_isDirty = this.m_isDirty;
newObject.m_protocolID = this.m_protocolID;
newObject.m_protocolName = this.m_protocolName;
newObject.m_protocolNumber = this.m_protocolNumber;
newObject.m_segments = new BOLProtocolSegmentList();
foreach(BOLProtocolSegment segment in this.m_segments)
{
newObject.m_segments.Add(segment);
}
return newObject;
}
</code>
How do I know that m_segments.Add() is creating a deep copy of segment?
I'm just looking for a little verification.
Thanks,
Steve
implemented IConeable and the Clone() method. However, I'm not sure I did
it correct. Is it suposed to be an allocation of a new object, then the
assignment of each member? Is that all or is there something else I need to
do?
Here is my code
<code>
public Object Clone()
{
BOLDeviceProtocol newObject = new BOLDeviceProtocol();
newObject.m_custom = this.m_custom;
newObject.m_dal = this.m_dal;
newObject.m_deviceProtocolID = this.m_deviceProtocolID;
newObject.m_deviceSettingsID = this.m_deviceSettingsID;
newObject.m_duration = this.m_duration;
newObject.m_enabled = this.m_enabled;
newObject.m_isDirty = this.m_isDirty;
newObject.m_protocolID = this.m_protocolID;
newObject.m_protocolName = this.m_protocolName;
newObject.m_protocolNumber = this.m_protocolNumber;
newObject.m_segments = new BOLProtocolSegmentList();
foreach(BOLProtocolSegment segment in this.m_segments)
{
newObject.m_segments.Add(segment);
}
return newObject;
}
</code>
How do I know that m_segments.Add() is creating a deep copy of segment?
I'm just looking for a little verification.
Thanks,
Steve