예제 #1
0
 public void Save()
 {
     using (UserConfiguration userConfiguration = UserConfigurationUtilities.GetUserConfiguration(this.configurationAttribute.ConfigurationName, this.userContext))
     {
         using (Stream xmlStream = userConfiguration.GetXmlStream())
         {
             xmlStream.SetLength(0L);
             using (StreamWriter streamWriter = Utilities.CreateStreamWriter(xmlStream))
             {
                 using (XmlTextWriter xmlTextWriter = new XmlTextWriter(streamWriter))
                 {
                     xmlTextWriter.WriteStartElement(this.configurationAttribute.ConfigurationRootNodeName);
                     foreach (T t in this.entries)
                     {
                         xmlTextWriter.WriteStartElement("entry");
                         foreach (SimpleConfigurationPropertyAttribute simpleConfigurationPropertyAttribute in this.configurationAttribute.GetPropertyCollection())
                         {
                             xmlTextWriter.WriteAttributeString(simpleConfigurationPropertyAttribute.Name, simpleConfigurationPropertyAttribute.GetValue(t).ToString());
                         }
                         xmlTextWriter.WriteFullEndElement();
                     }
                     xmlTextWriter.WriteFullEndElement();
                 }
             }
         }
         UserConfigurationUtilities.TrySaveConfiguration(userConfiguration);
     }
 }
        // Token: 0x060014F9 RID: 5369 RVA: 0x0007F560 File Offset: 0x0007D760
        public static UserConfiguration GetUserConfiguration(string configurationName, UserContext userContext)
        {
            if (string.IsNullOrEmpty(configurationName))
            {
                throw new ArgumentException("configurationName must not be null or empty");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            UserConfiguration userConfiguration = null;

            try
            {
                userConfiguration = userContext.MailboxSession.UserConfigurationManager.GetMailboxConfiguration(configurationName, UserConfigurationTypes.XML);
            }
            catch (ObjectNotFoundException)
            {
                userConfiguration = userContext.MailboxSession.UserConfigurationManager.CreateMailboxConfiguration(configurationName, UserConfigurationTypes.XML);
                try
                {
                    UserConfigurationUtilities.TrySaveConfiguration(userConfiguration, false);
                }
                catch (ObjectExistedException)
                {
                    try
                    {
                        userConfiguration = userContext.MailboxSession.UserConfigurationManager.GetMailboxConfiguration(configurationName, UserConfigurationTypes.XML);
                    }
                    catch (ObjectNotFoundException thisObject)
                    {
                        throw new OwaSaveConflictException("A save conflict happened during the creation and save of the userconfiguration.", thisObject);
                    }
                }
                catch (StoragePermanentException)
                {
                }
            }
            return(userConfiguration);
        }
 // Token: 0x060014FA RID: 5370 RVA: 0x0007F624 File Offset: 0x0007D824
 public static void TrySaveConfiguration(UserConfiguration configuration)
 {
     UserConfigurationUtilities.TrySaveConfiguration(configuration, true);
 }