コード例 #1
0
 public virtual void AddPhotographs(Photograph __item)
 {
     if (__item != null && photographs != null && !photographs.Contains(__item))
     {
         photographs.Add(__item);
         if (__item.PointOfInterest != this)
         {
             __item.PointOfInterest = this;
         }
     }
 }
コード例 #2
0
 public virtual void SetPhotographsAt(Photograph __item, int __index)
 {
     if (__item == null)
     {
         photographs[__index].Trip = null;
     }
     else
     {
         photographs[__index] = __item;
         if (__item.Trip != this)
         {
             __item.Trip = this;
         }
     }
 }
コード例 #3
0
 public virtual void SetPhotographsAt(Photograph __item, int __index)
 {
     if (__item == null)
     {
         photographs[__index].PointOfInterest = null;
     }
     else
     {
         photographs[__index] = __item;
         if (__item.PointOfInterest != this)
         {
             __item.PointOfInterest = this;
         }
     }
 }
コード例 #4
0
/// <summary>
///     Returns true if self and the provided entity have the same Id values
///     and the Ids are not of the default Id value
/// </summary>
        protected bool HasSameNonDefaultIdAs(Photograph compareTo)
        {
            return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id));
        }
コード例 #5
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 [Photograph] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual Photograph Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, Photograph copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((Photograph)copiedObjects[this]);
            }
            copy = copy ?? new Photograph();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.Name        = this.Name;
            copy.Description = this.Description;
            copy.Url         = this.Url;
            copy.File        = this.File;
            copy.IsPublic    = this.IsPublic;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            if (deep && this.geoCoordinates != null)
            {
                if (!copiedObjects.Contains(this.geoCoordinates))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.GeoCoordinates = this.GeoCoordinates;
                    }
                    else if (asNew)
                    {
                        copy.GeoCoordinates = this.GeoCoordinates.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.geoCoordinates = this.geoCoordinates.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.GeoCoordinates = (GeoCoordinates)copiedObjects[this.GeoCoordinates];
                    }
                    else
                    {
                        copy.geoCoordinates = (GeoCoordinates)copiedObjects[this.GeoCoordinates];
                    }
                }
            }
            copy.taggedPeople = new List <Person>();
            if (deep && this.taggedPeople != null)
            {
                foreach (var __item in this.taggedPeople)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddTaggedPeople(__item);
                        }
                        else
                        {
                            copy.AddTaggedPeople(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddTaggedPeople((Person)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.takenBy != null)
            {
                if (!copiedObjects.Contains(this.takenBy))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.TakenBy = this.TakenBy;
                    }
                    else if (asNew)
                    {
                        copy.TakenBy = this.TakenBy.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.takenBy = this.takenBy.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.TakenBy = (Person)copiedObjects[this.TakenBy];
                    }
                    else
                    {
                        copy.takenBy = (Person)copiedObjects[this.TakenBy];
                    }
                }
            }
            if (deep && this.pointOfInterest != null)
            {
                if (!copiedObjects.Contains(this.pointOfInterest))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.PointOfInterest = this.PointOfInterest;
                    }
                    else if (asNew)
                    {
                        copy.PointOfInterest = this.PointOfInterest.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.pointOfInterest = this.pointOfInterest.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.PointOfInterest = (PointOfInterest)copiedObjects[this.PointOfInterest];
                    }
                    else
                    {
                        copy.pointOfInterest = (PointOfInterest)copiedObjects[this.PointOfInterest];
                    }
                }
            }
            copy.likedBy = new List <Person>();
            if (deep && this.likedBy != null)
            {
                foreach (var __item in this.likedBy)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddLikedBy(__item);
                        }
                        else
                        {
                            copy.AddLikedBy(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddLikedBy((Person)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.leg != null)
            {
                if (!copiedObjects.Contains(this.leg))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Leg = this.Leg;
                    }
                    else if (asNew)
                    {
                        copy.Leg = this.Leg.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.leg = this.leg.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Leg = (Leg)copiedObjects[this.Leg];
                    }
                    else
                    {
                        copy.leg = (Leg)copiedObjects[this.Leg];
                    }
                }
            }
            if (deep && this.trip != null)
            {
                if (!copiedObjects.Contains(this.trip))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Trip = this.Trip;
                    }
                    else if (asNew)
                    {
                        copy.Trip = this.Trip.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.trip = this.trip.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Trip = (Trip)copiedObjects[this.Trip];
                    }
                    else
                    {
                        copy.trip = (Trip)copiedObjects[this.Trip];
                    }
                }
            }
            return(copy);
        }