示例#1
0
        public void MigrateOrMergeIdentities(List <NewsComponents.Feed.UserIdentity> oldVersionIdentities, bool replace)
        {
            if (oldVersionIdentities != null && oldVersionIdentities.Count > 0)
            {
                IdentitiesDictionary migrated = new IdentitiesDictionary(oldVersionIdentities.Count);
                foreach (NewsComponents.Feed.UserIdentity oldIdent in oldVersionIdentities)
                {
                    UserIdentity newIdent = new UserIdentity();
                    newIdent.Name            = oldIdent.Name;
                    newIdent.MailAddress     = oldIdent.MailAddress;
                    newIdent.Organization    = oldIdent.Organization;
                    newIdent.RealName        = oldIdent.RealName;
                    newIdent.ReferrerUrl     = oldIdent.ReferrerUrl;
                    newIdent.ResponseAddress = oldIdent.ResponseAddress;
                    newIdent.Signature       = oldIdent.Signature;
                    migrated.Add(newIdent.Name, newIdent);
                }

                if (replace)
                {
                    Identities = migrated;
                }
                else
                {
                    foreach (UserIdentity identity in migrated.Values)
                    {
                        if (Identities.ContainsKey(identity.Name))
                        {
                            Identities[identity.Name] = identity;
                        }
                        else
                        {
                            Identities.Add(identity.Name, identity);
                        }
                    }
                }

                Save();
            }
        }
示例#2
0
        private static void SaveIdentities(IClientDataService dataService, IdentitiesDictionary identitiesDictionary)
        {
            if (dataService == null)
            {
                throw new ArgumentNullException("dataService");
            }

            if (!identitiesDictionary.Modified)
            {
                return;
            }

            try
            {
                dataService.SaveIdentities(identitiesDictionary);
                identitiesDictionary.Modified = false;
            }
            catch (Exception ex)
            {
                _log.Error("Could not save user identities", ex);
            }
        }
示例#3
0
 /// <summary>
 /// Resets the identities. They are re-loaded from storage on next request
 /// </summary>
 public void Reset()
 {
     identities = null;
 }