コード例 #1
0
 public virtual void AddUserPreferences(UserPreference __item)
 {
     if (__item != null && userPreferences != null && !userPreferences.Contains(__item))
     {
         userPreferences.Add(__item);
         if (__item.Service != this)
         {
             __item.Service = this;
         }
     }
 }
コード例 #2
0
 public virtual void SetUserPreferencesAt(UserPreference __item, int __index)
 {
     if (__item == null)
     {
         userPreferences[__index].Service = null;
     }
     else
     {
         userPreferences[__index] = __item;
         if (__item.Service != this)
         {
             __item.Service = this;
         }
     }
 }
コード例 #3
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(UserPreference compareTo)
        {
            return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id));
        }
コード例 #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 [UserPreference] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual UserPreference Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, UserPreference copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((UserPreference)copiedObjects[this]);
            }
            copy = copy ?? new UserPreference();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.Name                 = this.Name;
            copy.Description          = this.Description;
            copy.Popularity           = this.Popularity;
            copy.PopularityPercentage = this.PopularityPercentage;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            if (deep && this.type != null)
            {
                if (!copiedObjects.Contains(this.type))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Type = this.Type;
                    }
                    else if (asNew)
                    {
                        copy.Type = this.Type.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.type = this.type.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Type = (UserPreferenceType)copiedObjects[this.Type];
                    }
                    else
                    {
                        copy.type = (UserPreferenceType)copiedObjects[this.Type];
                    }
                }
            }
            if (deep && this.service != null)
            {
                if (!copiedObjects.Contains(this.service))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Service = this.Service;
                    }
                    else if (asNew)
                    {
                        copy.Service = this.Service.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.service = this.service.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Service = (Service)copiedObjects[this.Service];
                    }
                    else
                    {
                        copy.service = (Service)copiedObjects[this.Service];
                    }
                }
            }
            return(copy);
        }