Пример #1
0
        public GroupMemberCollection Clone()
        {
            GroupMemberCollection newCollection = new GroupMemberCollection();

            newCollection.Add(this);
            return(newCollection);
        }
Пример #2
0
 /* FilterUniqueMember filter two hash sets so that they only contain
  * objects that are unique to each set.
  *
  * {A, B, C} and {C, D, E} => (FilterUniqueMember) => {A, B} and {D, E}
  */
 public void FilterUniqueMember(GroupMemberCollection collection)
 {
     // 1. Copy all members from set A (this set) to set B (set in collection),
     //    removing all members that exists in both sets. Now set B will contain
     //    all *unique* members from both sets.
     collection.SymmetricExceptWith(this);
     // 2. Remove all members from set A is not in set B. Now set A will only contain
     //    members that was unique to that set from the beginning.
     IntersectWith(collection);
     // 3. Remove all members from set B that is in set A. This does the same with
     //    set B, leaving only truly unique members in set B.
     collection.ExceptWith(this);
 }
Пример #3
0
 public GroupMemberDiff(GrouperDocument document, GroupMemberCollection addMemberCollection,
                        GroupMemberCollection removeMemberCollection, GroupMemberCollection unchangedMemberCollection,
                        double changeRatio)
 {
     Document    = document ?? throw new ArgumentNullException(nameof(document));
     Add         = addMemberCollection?.AsEnumerable() ?? throw new ArgumentNullException(nameof(addMemberCollection));
     Remove      = removeMemberCollection?.AsEnumerable() ?? throw new ArgumentNullException(nameof(removeMemberCollection));
     Unchanged   = unchangedMemberCollection?.AsEnumerable() ?? throw new ArgumentNullException(nameof(unchangedMemberCollection));
     ChangeRatio = changeRatio;
     if (addMemberCollection == removeMemberCollection || addMemberCollection == unchangedMemberCollection || removeMemberCollection == unchangedMemberCollection)
     {
         throw new ArgumentException("All collections must be separate objects");
     }
 }
Пример #4
0
        public bool ContainsMatchingMemberType(GroupMemberCollection collection)
        {
            if (Count == 0)
            {
                return(MemberTypesAsFlags(collection) < 3);
            }
            if (collection.Count == 0)
            {
                return(MemberTypesAsFlags(this) < 3);
            }
            int thisMemberTypes  = MemberTypesAsFlags(this);
            int otherMemberTypes = MemberTypesAsFlags(collection);

            return(thisMemberTypes == otherMemberTypes && thisMemberTypes < 3);
        }
Пример #5
0
        private static int MemberTypesAsFlags(GroupMemberCollection collection)
        {
            int flags = 0;

            foreach (GroupMember member in collection.AsEnumerable())
            {
                if (member.MemberType == GroupMemberTypes.OnPremAd)
                {
                    flags |= 1;
                }
                else // AzureAd
                {
                    flags |= 2;
                }
            }
            return(flags);
        }
Пример #6
0
 public GroupMemberDiff(GrouperDocument document, GroupMemberCollection addMemberCollection,
                        GroupMemberCollection removeMemberCollection, GroupMemberCollection unchangedMemberCollection,
                        double changeRatio)
 {
     if (addMemberCollection is null)
     {
         throw new ArgumentNullException(nameof(addMemberCollection));
     }
     if (removeMemberCollection is null)
     {
         throw new ArgumentNullException(nameof(removeMemberCollection));
     }
     if (unchangedMemberCollection is null)
     {
         throw new ArgumentNullException(nameof(unchangedMemberCollection));
     }
     Document    = document ?? throw new ArgumentNullException(nameof(document));
     Add         = addMemberCollection.AsEnumerable();
     Remove      = removeMemberCollection.AsEnumerable();
     Unchanged   = unchangedMemberCollection.AsEnumerable();
     ChangeRatio = changeRatio;
 }
Пример #7
0
 public void IntersectWith(GroupMemberCollection collection) => _members.IntersectWith(collection.AsEnumerable());
Пример #8
0
 public void SymmetricExceptWith(GroupMemberCollection collection) => _members.SymmetricExceptWith(collection.AsEnumerable());
Пример #9
0
 public void Add(GroupMemberCollection collection) => _members.UnionWith(collection.AsEnumerable());