.
This commit is contained in:
@@ -58,21 +58,21 @@ public class Hierarchy<T>
|
||||
});
|
||||
}
|
||||
|
||||
public void AddChild(T parEnt, T parChild)
|
||||
public void AddChild(T parParent, T parChild)
|
||||
{
|
||||
SetParent(parChild, parEnt);
|
||||
SetParent(parChild, parParent);
|
||||
}
|
||||
|
||||
private void SetParent(T parChild, T? parEnt)
|
||||
private void SetParent(T parChild, T? parParent)
|
||||
{
|
||||
if (parChild.Equals(parEnt))
|
||||
if (parChild.Equals(parParent))
|
||||
{
|
||||
throw new InvalidOperationException("Child cannot be parent");
|
||||
}
|
||||
|
||||
_hierarchyActions.Enqueue(() =>
|
||||
{
|
||||
if (IsInHierarchy(parChild, parEnt))
|
||||
if (IsInHierarchy(parChild, parParent))
|
||||
{
|
||||
throw new InvalidOperationException("Parent is a child of child");
|
||||
}
|
||||
@@ -80,8 +80,8 @@ public class Hierarchy<T>
|
||||
var oldParent = GetParent(parChild);
|
||||
_childrenLookup[oldParent].Remove(parChild);
|
||||
|
||||
_childrenLookup[parEnt].Add(parChild);
|
||||
_parentLookup[parChild] = parEnt;
|
||||
_childrenLookup[parParent].Add(parChild);
|
||||
_parentLookup[parChild] = parParent;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user