/// <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 [BookingQuery] instance to use as the destination.</param> /// <returns>A copy of the object</returns> public virtual BookingQuery Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, BookingQuery copy = null) { if (copiedObjects == null) { copiedObjects = new Hashtable(); } if (copy == null && copiedObjects.Contains(this)) { return((BookingQuery)copiedObjects[this]); } copy = copy ?? new BookingQuery(); if (!asNew) { copy.TransientId = this.TransientId; copy.Id = this.Id; } if (!copiedObjects.Contains(this)) { copiedObjects.Add(this, copy); } if (deep && this.shoppingQuery != null) { if (!copiedObjects.Contains(this.shoppingQuery)) { if (asNew && reuseNestedObjects) { copy.ShoppingQuery = this.ShoppingQuery; } else if (asNew) { copy.ShoppingQuery = this.ShoppingQuery.Copy(deep, copiedObjects, true); } else { copy.shoppingQuery = this.shoppingQuery.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.ShoppingQuery = (ShoppingQuery)copiedObjects[this.ShoppingQuery]; } else { copy.shoppingQuery = (ShoppingQuery)copiedObjects[this.ShoppingQuery]; } } } if (deep && this.vehicle != null) { if (!copiedObjects.Contains(this.vehicle)) { if (asNew && reuseNestedObjects) { copy.Vehicle = this.Vehicle; } else if (asNew) { copy.Vehicle = this.Vehicle.Copy(deep, copiedObjects, true); } else { copy.vehicle = this.vehicle.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.Vehicle = (Vehicle)copiedObjects[this.Vehicle]; } else { copy.vehicle = (Vehicle)copiedObjects[this.Vehicle]; } } } copy.person = new List <Person>(); if (deep && this.person != null) { foreach (var __item in this.person) { if (!copiedObjects.Contains(__item)) { if (asNew && reuseNestedObjects) { copy.AddPerson(__item); } else { copy.AddPerson(__item.Copy(deep, copiedObjects, asNew)); } } else { copy.AddPerson((Person)copiedObjects[__item]); } } } return(copy); }