private void Load(out IUserConfiguration initConfig, out AggregatedUserConfiguration.MementoClass initMemento, out Dictionary <UserConfigurationDescriptor.MementoClass, AggregatedUserConfigurationPart> initParts, out Dictionary <string, SerializableDataBase> initTypeBag) { initConfig = null; initMemento = null; initParts = null; Func <IUserConfiguration> read = () => this.manager.GetMailboxConfiguration(this.descriptor.Name, UserConfigurationTypes.XML); Func <IUserConfiguration> rebuild = delegate() { this.manager.DeleteMailboxConfigurations(new string[] { this.descriptor.Name }); return(this.manager.CreateMailboxConfiguration(this.descriptor.Name, UserConfigurationTypes.XML)); }; this.TryInternalLoadConfiguration(read, rebuild, delegate(IUserConfiguration c) { }, out initConfig); initMemento = this.ReadMemento(initConfig); initParts = new Dictionary <UserConfigurationDescriptor.MementoClass, AggregatedUserConfigurationPart>(); foreach (KeyValuePair <UserConfigurationDescriptor.MementoClass, AggregatedUserConfigurationPart.MementoClass> keyValuePair in initMemento.Parts) { AggregatedUserConfigurationPart value = AggregatedUserConfigurationPart.FromMemento(keyValuePair.Value); initParts.Add(keyValuePair.Key, value); } initTypeBag = initMemento.TypeBag; }
private AggregatedUserConfigurationPart(IUserConfiguration config) { this.memento = new AggregatedUserConfigurationPart.MementoClass { ConfigurationName = config.ConfigurationName, DataTypes = config.DataTypes, FolderId = config.FolderId, Id = config.Id, VersionedId = config.VersionedId, LastModifiedTime = config.LastModifiedTime.ToBinary() }; if ((config.DataTypes & UserConfigurationTypes.Dictionary) != (UserConfigurationTypes)0) { using (StringWriter stringWriter = new StringWriter()) { using (XmlWriter xmlWriter = AggregatedUserConfigurationPart.InternalGetXmlWriter(stringWriter)) { config.GetConfigurationDictionary().WriteXml(xmlWriter); xmlWriter.Flush(); this.memento.DictionaryXmlString = stringWriter.ToString(); } } } if ((config.DataTypes & UserConfigurationTypes.XML) != (UserConfigurationTypes)0) { using (Stream xmlStream = config.GetXmlStream()) { using (StreamReader streamReader = new StreamReader(xmlStream)) { this.memento.XmlString = streamReader.ReadToEnd(); } } } }
private void InitializeMissingParts() { bool flag = false; IEnumerable <UserConfigurationDescriptor> enumerable = Enumerable.Empty <UserConfigurationDescriptor>(); if (this.aggregatedConfiguration != null) { enumerable = from d in this.descriptor.Sources where !this.parts.ContainsKey(d.ToMemento(this.manager.MailboxSession)) select d; } using (IEnumerator <UserConfigurationDescriptor> enumerator = enumerable.GetEnumerator()) { while (enumerator.MoveNext()) { AggregatedUserConfiguration.< > c__DisplayClass1c CS$ < > 8__locals1 = new AggregatedUserConfiguration.< > c__DisplayClass1c(); CS$ < > 8__locals1.< > 4__this = this; CS$ < > 8__locals1.missingDescriptor = enumerator.Current; UserConfigurationDescriptor.MementoClass missingDescriptorMemento = CS$ < > 8__locals1.missingDescriptor.ToMemento(this.manager.MailboxSession); if (this.memento.FailedToLoad.Contains(missingDescriptorMemento)) { ExTraceGlobals.StorageTracer.TraceDebug <string>((long)this.GetHashCode(), "the missing configuration part with name=[{0}] failed to load once already and will not be initialized again", CS$ < > 8__locals1.missingDescriptor.ConfigurationName); } else { IUserConfiguration userConfiguration = null; try { if (!this.TryInternalLoadConfiguration(() => CS$ < > 8__locals1.missingDescriptor.GetConfiguration(CS$ < > 8__locals1.< > 4__this.manager), null, delegate(IUserConfiguration c) { CS$ < > 8__locals1.missingDescriptor.Validate(c); }, out userConfiguration)) { ExTraceGlobals.StorageTracer.TraceDebug <string>((long)this.GetHashCode(), "the missing configuration part with name=[{0}] failed to load", CS$ < > 8__locals1.missingDescriptor.ConfigurationName); this.memento.FailedToLoad.Add(missingDescriptorMemento); flag = true; } else { AggregatedUserConfigurationPart aggregatedUserConfigurationPart = AggregatedUserConfigurationPart.FromConfiguration(userConfiguration); this.parts[missingDescriptorMemento] = aggregatedUserConfigurationPart; if (this.memento.Pending.Exists((AggregatedUserConfiguration.PendingUpdate p) => missingDescriptorMemento.Equals(p.DescriptorMemento))) { ExTraceGlobals.StorageTracer.TraceDebug <string>((long)this.GetHashCode(), "the missing configuration part with name=[{0}] will not be persisted because it has a pending update", CS$ < > 8__locals1.missingDescriptor.ConfigurationName); } else { ExTraceGlobals.StorageTracer.TraceDebug <string>((long)this.GetHashCode(), "adding missing part {0} to the persisted aggregated configuration", CS$ < > 8__locals1.missingDescriptor.ConfigurationName); flag = true; this.memento.Parts.Add(missingDescriptorMemento, aggregatedUserConfigurationPart.Memento); } } }
public IDictionary GetDictionary() { IDictionary result; using (StringReader stringReader = new StringReader(this.Memento.DictionaryXmlString)) { using (XmlReader xmlReader = AggregatedUserConfigurationPart.InternalGetXmlReader(stringReader)) { ConfigurationDictionary configurationDictionary = new ConfigurationDictionary(); configurationDictionary.ReadXml(xmlReader); result = configurationDictionary; } } return(result); }
private void CommitUpdate(AggregatedUserConfiguration.PendingUpdate pending) { bool flag = true; if (this.memento.ConcurrentUpdates.Contains(pending.DescriptorMemento)) { flag = false; ExTraceGlobals.StorageTracer.TraceWarning <string>((long)this.GetHashCode(), "The configuration object with name[{0}] will not be committed because it is in the concurrent update list.", pending.Descriptor.ConfigurationName); } if (this.RemoveFromPendingAndConcurrent(pending) == 0) { flag = false; ExTraceGlobals.StorageTracer.TraceWarning <string>((long)this.GetHashCode(), "The configuration object with name[{0}] will not be committed because it was not found as a pending update.", pending.Descriptor.ConfigurationName); } if (flag) { IUserConfiguration userConfiguration = null; AggregatedUserConfigurationPart aggregatedUserConfigurationPart = null; try { if (this.TryInternalLoadConfiguration(() => pending.Descriptor.GetConfiguration(this.manager), null, delegate(IUserConfiguration c) { pending.Descriptor.Validate(c); }, out userConfiguration)) { aggregatedUserConfigurationPart = AggregatedUserConfigurationPart.FromConfiguration(userConfiguration); this.memento.Parts.Add(pending.DescriptorMemento, aggregatedUserConfigurationPart.Memento); this.memento.FailedToLoad.Remove(pending.DescriptorMemento); } } finally { DisposeGuard.DisposeIfPresent(userConfiguration); DisposeGuard.DisposeIfPresent(aggregatedUserConfigurationPart); } } this.SaveMemento(AggregatedUserConfiguration.SaveFailureMode.Fail); }