Class GroupHelper
This class contains helper methods related to stitch the groups back to the full hierarchy.
public class GroupHelper
- Inheritance
-
GroupHelper
- Inherited Members
Constructors
GroupHelper(Group)
Initializes a new instance of the GroupHelper class.
public GroupHelper(Group linkedGroup)
Parameters
GroupHelper(IEnumerable<Group>)
Initializes a new instance of the GroupHelper class.
public GroupHelper(IEnumerable<Group> allGroups)
Parameters
allGroups
IEnumerable<Group>The hierarchy represented as an one-dimensional collection of all hierarchy groups populated, at minimum, by immediate Id-only children and no parent.
Fields
Empty
The empty GroupHelper.
public static readonly GroupHelper Empty
Field Value
Methods
CloneGroup(Group, bool, bool)
Clones group structure.
public static Group CloneGroup(Group group, bool deepClone = false, bool keepParents = false)
Parameters
group
GroupThe original group.
deepClone
boolWhen true, the group is deeply cloned.
keepParents
boolWhen true, the parent group is added to the clone.
Returns
- Group
The cloned group.
CloneGroups(ICollection<Group>, IEnumerable<Group>, bool, bool)
Clones groups collection to cloneGroups collection.
public static bool CloneGroups(ICollection<Group> cloneGroups, IEnumerable<Group> groups, bool deepClone = false, bool keepParents = false)
Parameters
cloneGroups
ICollection<Group>The result of cloning.
groups
IEnumerable<Group>The original groups.
deepClone
boolWhen true, the groups are deeply cloned.
keepParents
boolWhen true, the parent groups are added to the clones.
Returns
- bool
True if groups collection is not empty.
GetGroup(Id)
public Group? GetGroup(Id groupId)
Parameters
Returns
GetPopulatedGroups(IEnumerable<Group>)
Populate the groups.
public IList<Group> GetPopulatedGroups(IEnumerable<Group> unpopulatedGroups)
Parameters
unpopulatedGroups
IEnumerable<Group>The unpopulated groups.
Returns
GetTrees()
Gets groups list where each group is a top parent of a linked tree.
public IList<Group> GetTrees()
Returns
HaveParentChildRelationship(IEnumerable<Group>?, Group)
Finds if any groups in a list have a parent child relationship to the group.
public static bool HaveParentChildRelationship(IEnumerable<Group>? groups, Group group)
Parameters
groups
IEnumerable<Group>The groups.
group
GroupThe group.
Returns
- bool
If any groups have a parent child relationship.
IsGroupsChanged(IList<Group>)
Determine if it is possible to simplify a list of groups based on highest group rule.
public (bool IsChanged, IList<Group> CanonicalGroups) IsGroupsChanged(IList<Group> groupsToCheck)
Parameters
Returns
- (bool IsChanged, IList<Group> CanonicalGroups)
Whether has changed and the canonical groups.
IsPathChildOf(Group?, Group?)
Checks to see the child group is a children of the parent using the path
public static bool IsPathChildOf(Group? parent, Group? child)
Parameters
Returns
Traverse(IEnumerable<Group>)
Returns a collection that traverses the tree.
public IEnumerable<Group> Traverse(IEnumerable<Group> groupsToTraverse)
Parameters
groupsToTraverse
IEnumerable<Group>The groups.
Returns
TraverseUp(IEnumerable<Group>)
Returns a collection that traverses the tree up.
public IList<Group> TraverseUp(IEnumerable<Group> groupsToTraverseUp)
Parameters
groupsToTraverseUp
IEnumerable<Group>The groups.