コード例 #1
0
 public virtual void RemoveRailRoute(RailRoute __item)
 {
     if (__item != null && railRoute != null && railRoute.Contains(__item))
     {
         railRoute.Remove(__item);
         __item.Train = null;
     }
 }
コード例 #2
0
 public virtual void AddRailRoute(RailRoute __item)
 {
     if (__item != null && railRoute != null && !railRoute.Contains(__item))
     {
         railRoute.Add(__item);
         if (__item.Train != this)
         {
             __item.Train = this;
         }
     }
 }
コード例 #3
0
 public virtual void SetRailRouteAt(RailRoute __item, int __index)
 {
     if (__item == null)
     {
         railRoute[__index].Train = null;
     }
     else
     {
         railRoute[__index] = __item;
         if (__item.Train != this)
         {
             __item.Train = this;
         }
     }
 }
コード例 #4
0
/// <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 [RailRoute] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual RailRoute Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, RailRoute copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((RailRoute)copiedObjects[this]);
            }
            copy = copy ?? new RailRoute();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
            }
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            if (deep && this.originStation != null)
            {
                if (!copiedObjects.Contains(this.originStation))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.OriginStation = this.OriginStation;
                    }
                    else if (asNew)
                    {
                        copy.OriginStation = this.OriginStation.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.originStation = this.originStation.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.OriginStation = (TrainStation)copiedObjects[this.OriginStation];
                    }
                    else
                    {
                        copy.originStation = (TrainStation)copiedObjects[this.OriginStation];
                    }
                }
            }
            if (deep && this.destinationStation != null)
            {
                if (!copiedObjects.Contains(this.destinationStation))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.DestinationStation = this.DestinationStation;
                    }
                    else if (asNew)
                    {
                        copy.DestinationStation = this.DestinationStation.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.destinationStation = this.destinationStation.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.DestinationStation = (TrainStation)copiedObjects[this.DestinationStation];
                    }
                    else
                    {
                        copy.destinationStation = (TrainStation)copiedObjects[this.DestinationStation];
                    }
                }
            }
            if (deep && this.marketingAgency != null)
            {
                if (!copiedObjects.Contains(this.marketingAgency))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.MarketingAgency = this.MarketingAgency;
                    }
                    else if (asNew)
                    {
                        copy.MarketingAgency = this.MarketingAgency.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.marketingAgency = this.marketingAgency.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.MarketingAgency = (RailAgency)copiedObjects[this.MarketingAgency];
                    }
                    else
                    {
                        copy.marketingAgency = (RailAgency)copiedObjects[this.MarketingAgency];
                    }
                }
            }
            if (deep && this.train != null)
            {
                if (!copiedObjects.Contains(this.train))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Train = this.Train;
                    }
                    else if (asNew)
                    {
                        copy.Train = this.Train.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.train = this.train.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Train = (Train)copiedObjects[this.Train];
                    }
                    else
                    {
                        copy.train = (Train)copiedObjects[this.Train];
                    }
                }
            }
            copy.trainStations = new List <TrainStation>();
            if (deep && this.trainStations != null)
            {
                foreach (var __item in this.trainStations)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddTrainStations(__item);
                        }
                        else
                        {
                            copy.AddTrainStations(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddTrainStations((TrainStation)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.operatingAgency != null)
            {
                if (!copiedObjects.Contains(this.operatingAgency))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.OperatingAgency = this.OperatingAgency;
                    }
                    else if (asNew)
                    {
                        copy.OperatingAgency = this.OperatingAgency.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.operatingAgency = this.operatingAgency.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.OperatingAgency = (RailAgency)copiedObjects[this.OperatingAgency];
                    }
                    else
                    {
                        copy.operatingAgency = (RailAgency)copiedObjects[this.OperatingAgency];
                    }
                }
            }
            base.Copy(deep, copiedObjects, asNew, reuseNestedObjects, copy);
            return(copy);
        }