/// <summary> /// Makes copies of reference-type members. This is a helper method for Cloning. /// </summary> /// <param name="dsEvent"></param> protected override void CopyTo(DockingStationEvent dsEvent) { // First, deep copy the base class. base.CopyTo(dsEvent); // Next, deep copy this subclass. InstrumentGasResponseEvent instrumentGasResponseEvent = (InstrumentGasResponseEvent)dsEvent; instrumentGasResponseEvent.GasResponses = new List <SensorGasResponse>(); foreach (SensorGasResponse sgr in this.GasResponses) { instrumentGasResponseEvent.GasResponses.Add((SensorGasResponse)sgr.Clone()); } instrumentGasResponseEvent.UsedGasEndPoints = new List <UsedGasEndPoint>(); foreach (UsedGasEndPoint u in this.UsedGasEndPoints) { instrumentGasResponseEvent.UsedGasEndPoints.Add((UsedGasEndPoint)u.Clone()); } instrumentGasResponseEvent.HighBumpFailCalGasResponses = new List <SensorGasResponse>(); foreach (SensorGasResponse sgr in this.HighBumpFailCalGasResponses) { instrumentGasResponseEvent.HighBumpFailCalGasResponses.Add((SensorGasResponse)sgr.Clone()); } }
/// <summary> /// Makes copies of reference-type members. This is a helper method for Cloning. /// </summary> /// <param name="dockingStationEvent"></param> protected override void CopyTo(DockingStationEvent dockingStationEvent) { base.CopyTo(dockingStationEvent); UploadDebugLogEvent uploadDebugLogAction = (UploadDebugLogEvent)dockingStationEvent; uploadDebugLogAction.LogText = this.LogText; // is this necessary? I think the memberwise clone handles this. }
/// <summary> /// Makes copies of reference-type members. This is a helper method for Cloning. /// </summary> /// <param name="dockingStationEvent"></param> protected override void CopyTo(DockingStationEvent dockingStationEvent) { base.CopyTo(dockingStationEvent); UploadDatabaseEvent uploadDatabaseEvent = (UploadDatabaseEvent)dockingStationEvent; if (((UploadDatabaseEvent)dockingStationEvent).File != null) { uploadDatabaseEvent.File = (byte[])((UploadDatabaseEvent)dockingStationEvent).File.Clone(); } }
/// <summary> /// Makes copies of reference-type members. This is a helper method for Cloning. /// </summary> /// <param name="dockingStationEvent"></param> protected override void CopyTo(DockingStationEvent dockingStationEvent) { base.CopyTo(dockingStationEvent); InstrumentDiagnosticEvent instrumentDiagnosticEvent = (InstrumentDiagnosticEvent)dockingStationEvent; instrumentDiagnosticEvent.Diagnostics = new List <Diagnostic>(); foreach (Diagnostic diagnostic in this.Diagnostics) { instrumentDiagnosticEvent.Diagnostics.Add((Diagnostic)diagnostic.Clone()); } }
/// <summary> /// Makes copies of reference-type members. This is a helper method for Cloning. /// </summary> /// <param name="dsEvent"></param> protected override void CopyTo(DockingStationEvent dsEvent) { base.CopyTo(dsEvent); DiagnosticEvent diagnosticEvent = (DiagnosticEvent)dsEvent; diagnosticEvent.Diagnostics = new List <Diagnostic>(this.Diagnostics.Count); // Loop through the docking station diagnostics calling clone for each one to fill the empty list. foreach (Diagnostic diagnostic in this.Diagnostics) { diagnosticEvent.Diagnostics.Add((Diagnostic)diagnostic.Clone()); } }
/// <summary> /// Makes copies of reference-type members. This is a helper method for Cloning. /// </summary> /// <param name="dockingStationEvent"></param> protected override void CopyTo(DockingStationEvent dockingStationEvent) { base.CopyTo(dockingStationEvent); InstrumentDatalogDownloadEvent instrumentHygieneDownloadEvent = (InstrumentDatalogDownloadEvent)dockingStationEvent; // Loop through instrument sessions calling clone for each one to fill the empty list. instrumentHygieneDownloadEvent.InstrumentSessions = new List <DatalogSession>(); foreach (DatalogSession session in this.InstrumentSessions) { instrumentHygieneDownloadEvent.InstrumentSessions.Add((DatalogSession)session.Clone()); } }
public virtual object Clone() { // First, do a shallow clone. DockingStationEvent dsEvent = (DockingStationEvent)this.MemberwiseClone(); // Next, do a deep copy. Note that CopyTo has a side effect of also doing a shallow copy // which we just did with the MemberwiseClone call. So, this Clone implementation actually // causes us to shallow-copy everything twice which is arguably a bit wasteful. But this // allows us to not have to implement Clone() in each and every subclass, and the subclaasses // don't generally have many member variables anyways. this.CopyTo(dsEvent); return(this); }
/// <summary> /// Makes copies of reference-type members. This is a helper method for Cloning. /// </summary> /// <param name="dockingStationEvent">Docking station event to be copied to</param> protected virtual void CopyTo(DockingStationEvent dsEvent) { dsEvent.DockingStation = ( DockingStation )this.DockingStation.Clone(); // Don't copy over top of the EventCode. We consider that property 'immutable'. //dsEvent.EventCode = this.EventCode; // Loop through error list calling clone for each one to fill the empty list. dsEvent.Errors.Clear(); foreach (DockingStationError error in this.Errors) { dsEvent.Errors.Add((DockingStationError)error.Clone()); } dsEvent.Schedule = this.Schedule; }
/// <summary> /// Makes copies of reference-type members. This is a helper method for Cloning. /// </summary> /// <param name="dsEvent"></param> protected override void CopyTo(DockingStationEvent dsEvent) { base.CopyTo(dsEvent); ExchangeStatusEvent exchangeStatusEvent = (ExchangeStatusEvent)dsEvent; if (this.InetStatus != null) { exchangeStatusEvent._inetStatus = (InetStatus)this.InetStatus.Clone(); } exchangeStatusEvent.ScheduledNowList = new List <ScheduledNow>(this.ScheduledNowList.Count); foreach (ScheduledNow scheduledNow in this.ScheduledNowList) { exchangeStatusEvent.ScheduledNowList.Add(scheduledNow); } }
/// <summary> /// Makes copies of reference-type members. This is a helper method for Cloning. /// </summary> /// <param name="dockingStationEvent"></param> protected override void CopyTo(DockingStationEvent dockingStationEvent) { base.CopyTo(dockingStationEvent); InstrumentAlarmEventsDownloadEvent instrumentAlarmEventsDownloadEvent = (InstrumentAlarmEventsDownloadEvent)dockingStationEvent; List <AlarmEvent> alarmEventList = new List <AlarmEvent>(); foreach (AlarmEvent alarmEvent in this.AlarmEvents) { alarmEventList.Add((AlarmEvent)alarmEvent.Clone()); } // Finally, any needed deep cloning of this subclass goes here... instrumentAlarmEventsDownloadEvent.AlarmEvents = alarmEventList.ToArray(); }