示例#1
0
        /// <summary>
        /// Add a member to the underlying membership data structure.
        /// </summary>
        /// <param name="servicetype"></param>
        /// <param name="account"></param>
        /// <param name="type"></param>
        /// <param name="memberrole"></param>
        /// <param name="member"></param>
        internal void AddMemberhip(ServiceName servicetype, string account, IMAddressInfoType type, RoleId memberrole, BaseMember member)
        {
            lock (SyncObject)
            {
                SerializableDictionary<RoleId, SerializableDictionary<string, BaseMember>> ms = SelectTargetMemberships(servicetype);
                if (ms != null)
                {
                    if (!ms.ContainsKey(memberrole))
                        ms.Add(memberrole, new SerializableDictionary<string, BaseMember>(0));

                    ms[memberrole][Contact.MakeHash(account, type)] = member;
                }
            }
        }
示例#2
0
 private static int CompareBaseMembers(BaseMember x, BaseMember y)
 {
     return x.LastChanged.CompareTo(y.LastChanged);
 }
示例#3
0
        private bool DetectBaseMember(BaseMember bm,
            out string account, out IMAddressInfoType type, out long cid, out string displayname)
        {
            bool ret = false;

            account = string.Empty;
            displayname = string.Empty;
            type = IMAddressInfoType.None;
            cid = 0;

            switch (bm.Type)
            {
                case MembershipType.Passport:
                    PassportMember pm = bm as PassportMember;

                    type = IMAddressInfoType.WindowsLive;
                    cid = pm.CID;

                    if (!pm.IsPassportNameHidden)
                    {
                        account = pm.PassportName;
                    }

                    break;

                case MembershipType.Email:

                    type = IMAddressInfoType.Yahoo;
                    account = ((EmailMember)bm).Email;

                    if (bm.Annotations != null)
                    {
                        foreach (Annotation anno in bm.Annotations)
                        {
                            switch (anno.Name)
                            {
                                case AnnotationNames.MSN_IM_BuddyType:
                                    if (!String.IsNullOrEmpty(anno.Value) && anno.Value.Contains(":"))
                                    {
                                        type = (IMAddressInfoType)int.Parse(anno.Value.Split(':')[0]);
                                    }
                                    break;
                            }
                        }
                    }

                    break;

                case MembershipType.Phone:
                    type = IMAddressInfoType.Telephone;
                    account = ((PhoneMember)bm).PhoneNumber;
                    break;

                case MembershipType.ExternalID:
                    type = IMAddressInfoType.RemoteNetwork;
                    account = ((ExternalIDMember)bm).SourceID;
                    break;

                case MembershipType.Domain:
                    account = ((DomainMember)bm).DomainName;
                    break;

                case MembershipType.Circle:
                    type = IMAddressInfoType.Circle;
                    account = ((CircleMember)bm).CircleId + "@" + Contact.DefaultHostDomain;
                    break;

                case MembershipType.Role:
                case MembershipType.Service:
                case MembershipType.Everyone:
                case MembershipType.Partner:
                    type = IMAddressInfoType.None;
                    account = bm.Type + "/" + bm.MembershipId;
                    break;
            }

            if (!String.IsNullOrEmpty(account) && type != IMAddressInfoType.None)
            {
                account = account.ToLowerInvariant();
                displayname = (bm.DisplayName == null) ? account : bm.DisplayName;
                ret = true;
            }

            return ret;
        }