/// <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();
            }
        }
        public bool Equals(CFAggregation other)
        {
            if (other == null)
            {
                return(false);
            }

            return(Guid == other.Guid &&
                   Id == other.Id);
        }
        public void RemoveChild(CFAggregation child)
        {
            lock (ChildConnectionLock)
            {
                CFAggregationHasMembers childConnection = ConnectionToChildren.Where(connection => connection.ChildId == child.Id).FirstOrDefault();

                if (childConnection != null)
                {
                    RemoveChild(childConnection);
                }
            }
        }
        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
            }
        }
        public void VisitHierarchy(Action <CFAggregation> visitor)
        {
            List <CFAggregation> toVisit = new List <CFAggregation>
            {
                this
            };

            for (int i = 0; i < toVisit.Count; ++i)
            {
                CFAggregation currentAggregation = toVisit[i];
                visitor(currentAggregation);
                foreach (CFAggregation child in currentAggregation.ChildMembers)
                {
                    //child.Guid
                    //if (!toVisit.Any(x => x.Guid == child.Guid))
                    if (!toVisit.Contains(child))
                    {
                        toVisit.Add(child);
                    }
                }
            }
        }
Example #6
0
 /// <summary>
 /// WARNING: Check for circular references first!
 /// </summary>
 /// <param name="child"></param>
 public void AppendParent(CFAggregation parent)
 {
     parent.ChildMembers.Add(this);
     this.ParentMembers.Add(parent);
 }
Example #7
0
 /// <summary>
 /// WARNING: Check for circular references first!
 /// </summary>
 /// <param name="child"></param>
 public void AppendChild(CFAggregation child)
 {
     this.ChildMembers.Add(child);
     child.ParentMembers.Add(this);
 }