示例#1
0
 public virtual void RemoveFlightSegments(FlightSegment __item)
 {
     if (__item != null && flightSegments != null && flightSegments.Contains(__item))
     {
         flightSegments.Remove(__item);
     }
 }
示例#2
0
 public virtual void AddFlightSegments(FlightSegment __item)
 {
     if (__item != null && flightSegments != null && !flightSegments.Contains(__item))
     {
         flightSegments.Add(__item);
     }
 }
示例#3
0
 public virtual void SetFlightSegmentsAt(FlightSegment __item, int __index)
 {
     if (__item == null)
     {
         flightSegments[__index] = null;
     }
     else
     {
         flightSegments[__index] = __item;
     }
 }
示例#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 [FlightSegment] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual FlightSegment Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, FlightSegment copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((FlightSegment)copiedObjects[this]);
            }
            copy = copy ?? new FlightSegment();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
            }
            copy.FlightTime = this.FlightTime;
            copy.DepartureDateTimeString = this.DepartureDateTimeString;
            copy.ArrivalDateTimeString   = this.ArrivalDateTimeString;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            if (deep && this.flightRoute != null)
            {
                if (!copiedObjects.Contains(this.flightRoute))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.FlightRoute = this.FlightRoute;
                    }
                    else if (asNew)
                    {
                        copy.FlightRoute = this.FlightRoute.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.flightRoute = this.flightRoute.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.FlightRoute = (FlightRoute)copiedObjects[this.FlightRoute];
                    }
                    else
                    {
                        copy.flightRoute = (FlightRoute)copiedObjects[this.FlightRoute];
                    }
                }
            }
            copy.classOfService = new List <ClassOfService>();
            if (deep && this.classOfService != null)
            {
                foreach (var __item in this.classOfService)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddClassOfService(__item);
                        }
                        else
                        {
                            copy.AddClassOfService(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddClassOfService((ClassOfService)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.chosenClassOfService != null)
            {
                if (!copiedObjects.Contains(this.chosenClassOfService))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.ChosenClassOfService = this.ChosenClassOfService;
                    }
                    else if (asNew)
                    {
                        copy.ChosenClassOfService = this.ChosenClassOfService.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.chosenClassOfService = this.chosenClassOfService.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.ChosenClassOfService = (ClassOfService)copiedObjects[this.ChosenClassOfService];
                    }
                    else
                    {
                        copy.chosenClassOfService = (ClassOfService)copiedObjects[this.ChosenClassOfService];
                    }
                }
            }
            base.Copy(deep, copiedObjects, asNew, reuseNestedObjects, copy);
            return(copy);
        }