public virtual void AddShippingLines(MarineRoute __item) { if (__item != null && shippingLines != null && !shippingLines.Contains(__item)) { shippingLines.Add(__item); if (!__item.IntermediatePorts.Contains(this)) { __item.AddIntermediatePorts(this); } } }
public virtual void SetShippingLinesAt(MarineRoute __item, int __index) { if (__item == null) { shippingLines[__index].RemoveIntermediatePorts(this); } else { shippingLines[__index] = __item; if (!__item.IntermediatePorts.Contains(this)) { __item.AddIntermediatePorts(this); } } }
/// <summary> /// Copies the current object to a new instance /// </summary> /// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param> /// <param name="copiedObjects">Objects that should be reused</param> /// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param> /// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param> /// <param name="copy">Optional - An existing [MarineRoute] instance to use as the destination.</param> /// <returns>A copy of the object</returns> public virtual MarineRoute Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, MarineRoute copy = null) { if (copiedObjects == null) { copiedObjects = new Hashtable(); } if (copy == null && copiedObjects.Contains(this)) { return((MarineRoute)copiedObjects[this]); } copy = copy ?? new MarineRoute(); if (!asNew) { copy.TransientId = this.TransientId; } if (!copiedObjects.Contains(this)) { copiedObjects.Add(this, copy); } if (deep && this.agency != null) { if (!copiedObjects.Contains(this.agency)) { if (asNew && reuseNestedObjects) { copy.Agency = this.Agency; } else if (asNew) { copy.Agency = this.Agency.Copy(deep, copiedObjects, true); } else { copy.agency = this.agency.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.Agency = (MarineAgency)copiedObjects[this.Agency]; } else { copy.agency = (MarineAgency)copiedObjects[this.Agency]; } } } copy.intermediatePorts = new List <Port>(); if (deep && this.intermediatePorts != null) { foreach (var __item in this.intermediatePorts) { if (!copiedObjects.Contains(__item)) { if (asNew && reuseNestedObjects) { copy.AddIntermediatePorts(__item); } else { copy.AddIntermediatePorts(__item.Copy(deep, copiedObjects, asNew)); } } else { copy.AddIntermediatePorts((Port)copiedObjects[__item]); } } } if (deep && this.ship != null) { if (!copiedObjects.Contains(this.ship)) { if (asNew && reuseNestedObjects) { copy.Ship = this.Ship; } else if (asNew) { copy.Ship = this.Ship.Copy(deep, copiedObjects, true); } else { copy.ship = this.ship.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.Ship = (Ferry)copiedObjects[this.Ship]; } else { copy.ship = (Ferry)copiedObjects[this.Ship]; } } } if (deep && this.origin != null) { if (!copiedObjects.Contains(this.origin)) { if (asNew && reuseNestedObjects) { copy.Origin = this.Origin; } else if (asNew) { copy.Origin = this.Origin.Copy(deep, copiedObjects, true); } else { copy.origin = this.origin.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.Origin = (Port)copiedObjects[this.Origin]; } else { copy.origin = (Port)copiedObjects[this.Origin]; } } } if (deep && this.destination != null) { if (!copiedObjects.Contains(this.destination)) { if (asNew && reuseNestedObjects) { copy.Destination = this.Destination; } else if (asNew) { copy.Destination = this.Destination.Copy(deep, copiedObjects, true); } else { copy.destination = this.destination.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.Destination = (Port)copiedObjects[this.Destination]; } else { copy.destination = (Port)copiedObjects[this.Destination]; } } } base.Copy(deep, copiedObjects, asNew, reuseNestedObjects, copy); return(copy); }