示例#1
0
        private IUserConfiguration RecreateUserConfiguration(MailboxSession mailboxSession, bool deleteFirst)
        {
            IUserConfiguration userConfiguration = null;
            bool flag = false;
            IUserConfiguration result;

            try
            {
                if (deleteFirst)
                {
                    this.accessStrategy.DeleteConfigurations(mailboxSession, new string[]
                    {
                        this.configurationName
                    });
                }
                userConfiguration = this.accessStrategy.CreateConfiguration(mailboxSession, this.configurationName, UserConfigurationTypes.Dictionary);
                userConfiguration.Save();
                flag   = true;
                result = userConfiguration;
            }
            catch (ObjectExistedException ex)
            {
                ExTraceGlobals.UserOptionsDataTracer.TraceWarning <string, string>((long)this.GetHashCode(), "User configuration data already created. Error: {0}. Stack: {1}.", ex.Message, ex.StackTrace);
                if (userConfiguration != null)
                {
                    userConfiguration.Dispose();
                }
                userConfiguration = this.accessStrategy.GetConfiguration(mailboxSession, this.configurationName, UserConfigurationTypes.Dictionary);
                flag   = true;
                result = userConfiguration;
            }
            catch (StoragePermanentException ex2)
            {
                ExTraceGlobals.UserOptionsDataTracer.TraceError <string, string>((long)this.GetHashCode(), "Failed to recreate configuration data. Error: {0}. Stack: {1}.", ex2.Message, ex2.StackTrace);
                throw;
            }
            catch (StorageTransientException ex3)
            {
                ExTraceGlobals.UserOptionsDataTracer.TraceError <string, string>((long)this.GetHashCode(), "Failed to recreate configuration data. Error: {0}. Stack: {1}.", ex3.Message, ex3.StackTrace);
                throw;
            }
            finally
            {
                if (!flag && userConfiguration != null)
                {
                    userConfiguration.Dispose();
                }
            }
            return(result);
        }