Exemplo n.º 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);
     }
 }
 public RecipientCacheTransaction(string configurationName, UserContext userContext)
 {
     using (DisposeGuard disposeGuard = this.Guard())
     {
         if (userContext.CanActAsOwner)
         {
             this.configuration = UserConfigurationUtilities.GetUserConfiguration(configurationName, userContext);
         }
         disposeGuard.Success();
     }
 }
Exemplo n.º 3
0
 public void Load()
 {
     this.entries.Clear();
     using (UserConfiguration userConfiguration = UserConfigurationUtilities.GetUserConfiguration(this.configurationAttribute.ConfigurationName, this.userContext))
     {
         using (Stream xmlStream = userConfiguration.GetXmlStream())
         {
             if (xmlStream != null && xmlStream.Length > 0L)
             {
                 this.reader = SafeXmlFactory.CreateSafeXmlTextReader(xmlStream);
                 this.Parse(this.reader);
             }
         }
     }
 }