Exemplo n.º 1
0
 public virtual void AddAtIndexShipment(int index, Shipment __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!shipment.Contains(__item))
     {
         shipment.Insert(index, __item);
     }
     if (!__item.ShippingOrders.Contains(this))
     {
         __item.AddShippingOrders(this);
     }
 }
Exemplo n.º 2
0
 public virtual void SetShipmentAt(Shipment __item, int __index)
 {
     if (__item == null)
     {
         shipment[__index].RemoveShippingOrders(this);
     }
     else
     {
         shipment[__index] = __item;
         if (!__item.ShippingOrders.Contains(this))
         {
             __item.AddShippingOrders(this);
         }
     }
 }
Exemplo n.º 3
0
 public virtual void AddShipment(Shipment __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!shipment.Contains(__item))
     {
         InternalAddShipment(__item);
     }
     if (!__item.ShippingOrders.Contains(this))
     {
         __item.AddShippingOrders(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 [Shipment] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual Shipment Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, Shipment copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((Shipment)copiedObjects[this]);
            }
            copy = copy ?? new Shipment();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.Owner          = this.Owner;
            copy.DepartureTime  = this.DepartureTime;
            copy.CurrentStatus  = this.CurrentStatus;
            copy.Temperature    = this.Temperature;
            copy.LoadPercentage = this.LoadPercentage;
            copy.TotalVolume    = this.TotalVolume;
            copy.AverageVolume  = this.AverageVolume;
            copy.MaxTravelTime  = this.MaxTravelTime;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            copy.shippingOrders = new List <ShippingOrder>();
            if (deep && this.shippingOrders != null)
            {
                foreach (var __item in this.shippingOrders)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddShippingOrders(__item);
                        }
                        else
                        {
                            copy.AddShippingOrders(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddShippingOrders((ShippingOrder)copiedObjects[__item]);
                    }
                }
            }
            copy.shipmentStatus = new List <ShipmentStatus>();
            if (deep && this.shipmentStatus != null)
            {
                foreach (var __item in this.shipmentStatus)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddShipmentStatus(__item);
                        }
                        else
                        {
                            copy.AddShipmentStatus(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddShipmentStatus((ShipmentStatus)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.departurePoint != null)
            {
                if (!copiedObjects.Contains(this.departurePoint))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.DeparturePoint = this.DeparturePoint;
                    }
                    else if (asNew)
                    {
                        copy.DeparturePoint = this.DeparturePoint.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.departurePoint = this.departurePoint.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.DeparturePoint = (Location)copiedObjects[this.DeparturePoint];
                    }
                    else
                    {
                        copy.departurePoint = (Location)copiedObjects[this.DeparturePoint];
                    }
                }
            }
            if (deep && this.finalDestination != null)
            {
                if (!copiedObjects.Contains(this.finalDestination))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.FinalDestination = this.FinalDestination;
                    }
                    else if (asNew)
                    {
                        copy.FinalDestination = this.FinalDestination.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.finalDestination = this.finalDestination.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.FinalDestination = (Location)copiedObjects[this.FinalDestination];
                    }
                    else
                    {
                        copy.finalDestination = (Location)copiedObjects[this.FinalDestination];
                    }
                }
            }
            if (deep && this.driver != null)
            {
                if (!copiedObjects.Contains(this.driver))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Driver = this.Driver;
                    }
                    else if (asNew)
                    {
                        copy.Driver = this.Driver.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.driver = this.driver.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Driver = (Driver)copiedObjects[this.Driver];
                    }
                    else
                    {
                        copy.driver = (Driver)copiedObjects[this.Driver];
                    }
                }
            }
            if (deep && this.occupiedVolume != null)
            {
                if (!copiedObjects.Contains(this.occupiedVolume))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.OccupiedVolume = this.OccupiedVolume;
                    }
                    else if (asNew)
                    {
                        copy.OccupiedVolume = this.OccupiedVolume.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.occupiedVolume = this.occupiedVolume.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.OccupiedVolume = (CustomVolume)copiedObjects[this.OccupiedVolume];
                    }
                    else
                    {
                        copy.occupiedVolume = (CustomVolume)copiedObjects[this.OccupiedVolume];
                    }
                }
            }
            copy.acceptedConditions = new List <Condition>();
            if (deep && this.acceptedConditions != null)
            {
                foreach (var __item in this.acceptedConditions)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddAcceptedConditions(__item);
                        }
                        else
                        {
                            copy.AddAcceptedConditions(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddAcceptedConditions((Condition)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.vehiculeType != null)
            {
                if (!copiedObjects.Contains(this.vehiculeType))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.VehiculeType = this.VehiculeType;
                    }
                    else if (asNew)
                    {
                        copy.VehiculeType = this.VehiculeType.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.vehiculeType = this.vehiculeType.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.VehiculeType = (Vehicule)copiedObjects[this.VehiculeType];
                    }
                    else
                    {
                        copy.vehiculeType = (Vehicule)copiedObjects[this.VehiculeType];
                    }
                }
            }
            copy.path = new List <Point>();
            if (deep && this.path != null)
            {
                foreach (var __item in this.path)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddPath(__item);
                        }
                        else
                        {
                            copy.AddPath(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddPath((Point)copiedObjects[__item]);
                    }
                }
            }
            return(copy);
        }