Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
0
        public bool Equals(CFAggregation other)
        {
            if (other == null)
            {
                return(false);
            }

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

                if (childConnection != null)
                {
                    RemoveChild(childConnection);
                }
            }
        }
Ejemplo n.º 4
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
            }
        }
Ejemplo n.º 5
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }