Пример #1
0
        /// <summary>
        /// WARNING: Check for circular references first!
        /// </summary>
        /// <param name="child"></param>
        public void AddChild(CFAggregation child, int order = -1)
        {
            lock (ChildConnectionLock)
            {
                CFAggregationHasMembers member = new CFAggregationHasMembers();
                member.Parent = this;
                member.Child  = child;

                if (order < 0 || order >= ConnectionToChildren.Count)
                {
                    member.Order = ConnectionToChildren.Count;
                    ConnectionToChildren.Add(member);
                }
                else
                {
                    member.Order = order;
                    //RefreshChildrenOrdering(order, 1); // This is currently breaking the system
                    ConnectionToChildren.Add(member);
                }

                child.ConnectionToParents.Add(member);

                child.ResetPermissions();
            }
        }
Пример #2
0
        public void RemoveChild(CFAggregation child)
        {
            lock (ChildConnectionLock)
            {
                CFAggregationHasMembers childConnection = ConnectionToChildren.Where(connection => connection.ChildId == child.Id).FirstOrDefault();

                if (childConnection != null)
                {
                    RemoveChild(childConnection);
                }
            }
        }
Пример #3
0
        public void RemoveChild(CFAggregationHasMembers connection)
        {
            lock (ChildConnectionLock)
            {
                CFAggregation child = connection.Child;

                ConnectionToChildren.Remove(connection);
                child.ConnectionToParents.Remove(connection);
                child.ResetPermissions();

                //RefreshChildrenOrdering(connection.Order + 1, -1); // This is currently breaking the system
            }
        }