protected void AssertValidMembers()
{
//only check existing groups
if (this.Id == 0)
return;
if (RepositoryConfiguration.SpecialGroupNames.Contains(this.Name))
{
if (this.Members.Count() > 0)
throw new InvalidOperationException(string.Format("The {0} group is a special system group, members cannot be added to it.", this.DisplayName));
}
foreach (var member in this.Members)
{
var group = member as Group;
if (group == null)
continue;
if (group.Id == this.Id)
throw new InvalidOperationException(string.Format("Group cannot contain itself as a member. Please remove {0} from the Members list.", this.DisplayName));
if (this.Security.IsInGroup(group.Id))
throw new InvalidOperationException(string.Format("Circular group membership is not allowed. Please remove {0} from the Members list.", group.DisplayName));
}
}