/// <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 [ApplicationOperation] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual ApplicationOperation Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, ApplicationOperation copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((ApplicationOperation)copiedObjects[this]);
            }
            copy = copy ?? new ApplicationOperation();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.Name = this.Name;
            copy.ParentControllerName = this.ParentControllerName;
            copy.Type = this.Type;
            copy.IsAvailableToAnonymous          = this.IsAvailableToAnonymous;
            copy.IsAvailableToAllAuthorizedUsers = this.IsAvailableToAllAuthorizedUsers;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            copy.permissions = new List <ApplicationPermission>();
            if (deep && this.permissions != null)
            {
                foreach (var __item in this.permissions)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddPermissions(__item);
                        }
                        else
                        {
                            copy.AddPermissions(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddPermissions((ApplicationPermission)copiedObjects[__item]);
                    }
                }
            }
            return(copy);
        }
 public virtual void AddAtIndexOperations(int index, ApplicationOperation __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!operations.Contains(__item))
     {
         operations.Insert(index, __item);
     }
     if (!__item.Permissions.Contains(this))
     {
         __item.AddPermissions(this);
     }
 }
 public virtual void SetOperationsAt(ApplicationOperation __item, int __index)
 {
     if (__item == null)
     {
         operations[__index].RemovePermissions(this);
     }
     else
     {
         operations[__index] = __item;
         if (!__item.Permissions.Contains(this))
         {
             __item.AddPermissions(this);
         }
     }
 }
 public virtual void AddOperations(ApplicationOperation __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!operations.Contains(__item))
     {
         InternalAddOperations(__item);
     }
     if (!__item.Permissions.Contains(this))
     {
         __item.AddPermissions(this);
     }
 }