Пример #1
0
 public virtual void RemoveTrainStations(TrainStation __item)
 {
     if (__item != null && trainStations != null && trainStations.Contains(__item))
     {
         trainStations.Remove(__item);
     }
 }
Пример #2
0
 public virtual void AddTrainStations(TrainStation __item)
 {
     if (__item != null && trainStations != null && !trainStations.Contains(__item))
     {
         trainStations.Add(__item);
     }
 }
Пример #3
0
 public virtual void RemoveMemberStations(TrainStation __item)
 {
     if (__item != null && memberStations != null && memberStations.Contains(__item))
     {
         memberStations.Remove(__item);
         __item.ParentStation = null;
     }
 }
Пример #4
0
 public virtual void SetTrainStationsAt(TrainStation __item, int __index)
 {
     if (__item == null)
     {
         trainStations[__index] = null;
     }
     else
     {
         trainStations[__index] = __item;
     }
 }
Пример #5
0
 public virtual void AddMemberStations(TrainStation __item)
 {
     if (__item != null && memberStations != null && !memberStations.Contains(__item))
     {
         memberStations.Add(__item);
         if (__item.ParentStation != this)
         {
             __item.ParentStation = this;
         }
     }
 }
Пример #6
0
 public virtual void SetMemberStationsAt(TrainStation __item, int __index)
 {
     if (__item == null)
     {
         memberStations[__index].ParentStation = null;
     }
     else
     {
         memberStations[__index] = __item;
         if (__item.ParentStation != this)
         {
             __item.ParentStation = this;
         }
     }
 }
Пример #7
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 [TrainStation] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual TrainStation Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, TrainStation copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((TrainStation)copiedObjects[this]);
            }
            copy = copy ?? new TrainStation();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
            }
            copy.FareStation             = this.FareStation;
            copy.ItineraryStation        = this.ItineraryStation;
            copy.IsMainStation           = this.IsMainStation;
            copy.StateProvinceCode       = this.StateProvinceCode;
            copy.NameOnPrintedTicket     = this.NameOnPrintedTicket;
            copy.IATACode                = this.IATACode;
            copy.TrainOperatingCompany   = this.TrainOperatingCompany;
            copy.TicketIssuingSystem     = this.TicketIssuingSystem;
            copy.HasTicketOffice         = this.HasTicketOffice;
            copy.HasTicketVendingMachine = this.HasTicketVendingMachine;
            copy.TrenitaliaStationCode   = this.TrenitaliaStationCode;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            if (deep && this.country != null)
            {
                if (!copiedObjects.Contains(this.country))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Country = this.Country;
                    }
                    else if (asNew)
                    {
                        copy.Country = this.Country.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.country = this.country.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Country = (Country)copiedObjects[this.Country];
                    }
                    else
                    {
                        copy.country = (Country)copiedObjects[this.Country];
                    }
                }
            }
            if (deep && this.timezone != null)
            {
                if (!copiedObjects.Contains(this.timezone))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Timezone = this.Timezone;
                    }
                    else if (asNew)
                    {
                        copy.Timezone = this.Timezone.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.timezone = this.timezone.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Timezone = (Timezone)copiedObjects[this.Timezone];
                    }
                    else
                    {
                        copy.timezone = (Timezone)copiedObjects[this.Timezone];
                    }
                }
            }
            if (deep && this.parentStation != null)
            {
                if (!copiedObjects.Contains(this.parentStation))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.ParentStation = this.ParentStation;
                    }
                    else if (asNew)
                    {
                        copy.ParentStation = this.ParentStation.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.parentStation = this.parentStation.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.ParentStation = (TrainStation)copiedObjects[this.ParentStation];
                    }
                    else
                    {
                        copy.parentStation = (TrainStation)copiedObjects[this.ParentStation];
                    }
                }
            }
            copy.memberStations = new List <TrainStation>();
            if (deep && this.memberStations != null)
            {
                foreach (var __item in this.memberStations)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddMemberStations(__item);
                        }
                        else
                        {
                            copy.AddMemberStations(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddMemberStations((TrainStation)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.city != null)
            {
                if (!copiedObjects.Contains(this.city))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.City = this.City;
                    }
                    else if (asNew)
                    {
                        copy.City = this.City.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.city = this.city.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.City = (City)copiedObjects[this.City];
                    }
                    else
                    {
                        copy.city = (City)copiedObjects[this.City];
                    }
                }
            }
            copy.railAgencies = new List <RailAgency>();
            if (deep && this.railAgencies != null)
            {
                foreach (var __item in this.railAgencies)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddRailAgencies(__item);
                        }
                        else
                        {
                            copy.AddRailAgencies(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddRailAgencies((RailAgency)copiedObjects[__item]);
                    }
                }
            }
            base.Copy(deep, copiedObjects, asNew, reuseNestedObjects, copy);
            return(copy);
        }