コード例 #1
0
 public virtual void AddAtIndexPermissions(int index, ApplicationPermission __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!permissions.Contains(__item))
     {
         permissions.Insert(index, __item);
     }
     if (!__item.Users.Contains(this))
     {
         __item.AddUsers(this);
     }
 }
コード例 #2
0
 public virtual void SetPermissionsAt(ApplicationPermission __item, int __index)
 {
     if (__item == null)
     {
         permissions[__index].RemoveUsers(this);
     }
     else
     {
         permissions[__index] = __item;
         if (!__item.Users.Contains(this))
         {
             __item.AddUsers(this);
         }
     }
 }
コード例 #3
0
 public virtual void AddPermissions(ApplicationPermission __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!permissions.Contains(__item))
     {
         InternalAddPermissions(__item);
     }
     if (!__item.Users.Contains(this))
     {
         __item.AddUsers(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 [ApplicationPermission] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual ApplicationPermission Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, ApplicationPermission copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((ApplicationPermission)copiedObjects[this]);
            }
            copy = copy ?? new ApplicationPermission();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.Name        = this.Name;
            copy.Description = this.Description;
            copy.IsCustom    = this.IsCustom;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            copy.users = new List <ApplicationUser>();
            if (deep && this.users != null)
            {
                foreach (var __item in this.users)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddUsers(__item);
                        }
                        else
                        {
                            copy.AddUsers(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddUsers((ApplicationUser)copiedObjects[__item]);
                    }
                }
            }
            copy.roles = new List <ApplicationRole>();
            if (deep && this.roles != null)
            {
                foreach (var __item in this.roles)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddRoles(__item);
                        }
                        else
                        {
                            copy.AddRoles(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddRoles((ApplicationRole)copiedObjects[__item]);
                    }
                }
            }
            copy.operations = new List <ApplicationOperation>();
            if (deep && this.operations != null)
            {
                foreach (var __item in this.operations)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddOperations(__item);
                        }
                        else
                        {
                            copy.AddOperations(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddOperations((ApplicationOperation)copiedObjects[__item]);
                    }
                }
            }
            return(copy);
        }