Esempio n. 1
0
        internal void UnlinkContact(ContactInfoForLinking contactBeingUnlinked, IList <ContactInfoForLinking> linkedContacts)
        {
            Util.ThrowOnNullArgument(contactBeingUnlinked, "contactBeingUnlinked");
            Util.ThrowOnNullArgument(linkedContacts, "linkedContacts");
            Util.ThrowOnArgumentOutOfRangeOnLessThan(linkedContacts.Count, 1, "linkedContacts");
            bool flag = ManualLink.IsGALLinked(linkedContacts);

            if (linkedContacts.Count == 1 && flag)
            {
                this.UnlinkContactFromGAL(linkedContacts);
                return;
            }
            if (linkedContacts.Count > 1)
            {
                PersonId personId = linkedContacts[0].PersonId;
                contactBeingUnlinked.ClearGALLink(flag ? GALLinkState.NotAllowed : GALLinkState.NotLinked);
                contactBeingUnlinked.Linked            = false;
                contactBeingUnlinked.PersonId          = PersonId.CreateNew();
                contactBeingUnlinked.LinkRejectHistory = new HashSet <PersonId>(new PersonId[]
                {
                    personId
                });
                contactBeingUnlinked.UserApprovedLink = false;
                HashSet <PersonId> hashSet = new HashSet <PersonId>();
                if (!contactBeingUnlinked.PersonId.Equals(personId))
                {
                    hashSet.Add(contactBeingUnlinked.PersonId);
                }
                foreach (ContactInfoForLinking contactInfoForLinking in linkedContacts)
                {
                    if (!contactInfoForLinking.ItemId.ObjectId.Equals(contactBeingUnlinked.ItemId.ObjectId))
                    {
                        hashSet.UnionWith(contactInfoForLinking.LinkRejectHistory);
                    }
                }
                bool flag2 = linkedContacts.Count == 2 && !flag;
                using (IEnumerator <ContactInfoForLinking> enumerator2 = linkedContacts.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        ContactInfoForLinking contactInfoForLinking2 = enumerator2.Current;
                        if (!contactInfoForLinking2.ItemId.ObjectId.Equals(contactBeingUnlinked.ItemId.ObjectId))
                        {
                            contactInfoForLinking2.UserApprovedLink  = true;
                            contactInfoForLinking2.LinkRejectHistory = hashSet;
                            if (flag2)
                            {
                                contactInfoForLinking2.Linked = false;
                            }
                        }
                    }
                    return;
                }
            }
            ContactLink.Tracer.TraceDebug <VersionedId, string>((long)this.GetHashCode(), "ManualLink.Unlink: contact is not linked with other contacts", contactBeingUnlinked.ItemId, contactBeingUnlinked.GivenName);
        }
 protected ContactInfoForLinking(bool linked, PersonId personId, HashSet <PersonId> linkRejectHistory, Guid?galLinkID, byte[] addressBookEntryId, GALLinkState galLinkState, string[] smtpAddressCache, bool userApprovedLink)
 {
     Util.ThrowOnNullArgument(linkRejectHistory, "linkRejectHistory");
     Util.ThrowOnNullArgument(smtpAddressCache, "smtpAddressCache");
     if (personId == null)
     {
         this.personId = PersonId.CreateNew();
         this.isDirty  = true;
     }
     else
     {
         this.personId = personId;
     }
     this.linked             = linked;
     this.linkRejectHistory  = linkRejectHistory;
     this.galLinkID          = galLinkID;
     this.addressBookEntryId = addressBookEntryId;
     this.galLinkState       = galLinkState;
     this.smtpAddressCache   = smtpAddressCache;
     this.userApprovedLink   = userApprovedLink;
 }