示例#1
0
 private void LoadUserConfigurationToConfigObject(string userConfigurationName, XsoMailboxConfigurationObject configObject)
 {
     using (IReadableUserConfiguration readableUserConfiguration = this.getReadOnlyUserConfiguration(base.MailboxSession, userConfigurationName, UserConfigurationTypes.Dictionary, false))
     {
         if (readableUserConfiguration != null)
         {
             IDictionary dictionary = readableUserConfiguration.GetDictionary();
             foreach (PropertyDefinition propertyDefinition in configObject.Schema.AllProperties)
             {
                 XsoDictionaryPropertyDefinition xsoDictionaryPropertyDefinition = propertyDefinition as XsoDictionaryPropertyDefinition;
                 if (xsoDictionaryPropertyDefinition != null && !(xsoDictionaryPropertyDefinition.UserConfigurationName != userConfigurationName) && dictionary.Contains(xsoDictionaryPropertyDefinition.Name))
                 {
                     configObject.propertyBag.SetField(xsoDictionaryPropertyDefinition, StoreValueConverter.ConvertValueFromStore(xsoDictionaryPropertyDefinition, dictionary[xsoDictionaryPropertyDefinition.Name]));
                 }
             }
         }
     }
 }
示例#2
0
        private void SaveConfigObjectToUserConfiguration(string userConfigurationName, XsoMailboxConfigurationObject configObject)
        {
            bool flag = false;
            int  num  = 0;

            do
            {
                using (IUserConfiguration userConfiguration = this.getUserConfiguration(base.MailboxSession, userConfigurationName, UserConfigurationTypes.Dictionary, !flag))
                {
                    if (userConfiguration != null)
                    {
                        IDictionary dictionary;
                        try
                        {
                            dictionary = userConfiguration.GetDictionary();
                        }
                        catch (CorruptDataException)
                        {
                            ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "The calendar configuration for {0} is corrupt", base.MailboxSession.MailboxOwner);
                            dictionary = new ConfigurationDictionary();
                        }
                        catch (VirusDetectedException)
                        {
                            ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "The calendar configuration for {0} is virus infected.", base.MailboxSession.MailboxOwner);
                            dictionary = new ConfigurationDictionary();
                        }
                        foreach (PropertyDefinition propertyDefinition in configObject.Schema.AllProperties)
                        {
                            XsoDictionaryPropertyDefinition xsoDictionaryPropertyDefinition = propertyDefinition as XsoDictionaryPropertyDefinition;
                            if (xsoDictionaryPropertyDefinition != null && !xsoDictionaryPropertyDefinition.IsReadOnly && !(xsoDictionaryPropertyDefinition.UserConfigurationName != userConfigurationName) && configObject.IsModified(xsoDictionaryPropertyDefinition))
                            {
                                object obj = configObject[xsoDictionaryPropertyDefinition];
                                if (obj == null || (obj is ICollection && ((ICollection)obj).Count == 0))
                                {
                                    dictionary.Remove(xsoDictionaryPropertyDefinition.Name);
                                }
                                else
                                {
                                    dictionary[xsoDictionaryPropertyDefinition.Name] = StoreValueConverter.ConvertValueToStore(obj);
                                }
                            }
                        }
                        try
                        {
                            ExTraceGlobals.FaultInjectionTracer.TraceTest(4289080637U);
                            userConfiguration.Save();
                            break;
                        }
                        catch (ObjectExistedException)
                        {
                            if (flag)
                            {
                                throw;
                            }
                            flag = true;
                        }
                        catch (SaveConflictException)
                        {
                            if (num >= 5)
                            {
                                throw;
                            }
                            num++;
                            flag = true;
                        }
                    }
                }
            }while (flag);
        }