public bool IsMemberGroup(Group group, GroupMember memberGroup) { var isMember = false; foreach (var member in group.GroupMembers.Where(x => x.IsGroup)) { if (memberGroup.Equals(member)) { isMember = true; } else { var nestedGroup = this.groupRepository.GroupNamed(member.TenantId, member.Name); if (nestedGroup != null) { isMember = IsMemberGroup(nestedGroup, memberGroup); } } if (isMember) { break; } } return(isMember); }
private bool IsMemberGroup(Group group, GroupMember memberGroup, int recursionCount) { if (recursionCount > MaxGroupNestingRecursion) { throw new InvalidOperationException("The maximum depth of group nesting has been exceeded, stopping recursive function."); } bool isMember = false; foreach (GroupMember member in group.GroupMembers.Where(x => x.IsGroup)) { if (memberGroup.Equals(member)) { isMember = true; } else { Group nestedGroup = _groupRepository.GroupNamed(member.TenantId, member.Name); if (nestedGroup != null) { int nextRecursionCount = (recursionCount + 1); isMember = IsMemberGroup(nestedGroup, memberGroup, nextRecursionCount); } } if (isMember) { break; } } return(isMember); }
public bool IsMemberGroup(Group group, GroupMember memberGroup) { bool isMember = false; foreach (GroupMember member in group.GroupMembers) { if (member.IsGroup()) { if (memberGroup.Equals(member)) { isMember = true; } else { Group nestedGroup = this.GroupRepository.GroupNamed(member.TenantId, member.Name); if (nestedGroup != null) { isMember = this.IsMemberGroup(nestedGroup, memberGroup); } } } if (isMember) { break; } } return isMember; }
public bool IsMemberGroup(Group group, GroupMember memberGroup) { var isMember = false; foreach (var member in group.GroupMembers.Where(x => x.IsGroup)) { if (memberGroup.Equals(member)) { isMember = true; } else { var nestedGroup = this.groupRepository.GroupNamed(member.TenantId, member.Name); if (nestedGroup != null) { isMember = IsMemberGroup(nestedGroup, memberGroup); } } if (isMember) { break; } } return isMember; }
private bool IsMemberGroup(Group group, GroupMember memberGroup, int recursionCount) { if (recursionCount > MaxGroupNestingRecursion) { throw new InvalidOperationException("The maximum depth of group nesting has been exceeded, stopping recursive function."); } bool isMember = false; foreach (GroupMember member in group.GroupMembers.Where(x => x.IsGroup)) { if (memberGroup.Equals(member)) { isMember = true; } else { Group nestedGroup = this.groupRepository.GroupNamed(member.TenantId, member.Name); if (nestedGroup != null) { int nextRecursionCount = (recursionCount + 1); isMember = this.IsMemberGroup(nestedGroup, memberGroup, nextRecursionCount); } } if (isMember) { break; } } return isMember; }