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 AggregatedUserConfiguration.MementoClass ReadMemento(IUserConfiguration aggregated)
 {
     AggregatedUserConfiguration.MementoClass mementoClass = null;
     try
     {
         if (aggregated != null)
         {
             DataContractSerializer dataContractSerializer = new DataContractSerializer(typeof(AggregatedUserConfiguration.MementoClass));
             using (Stream xmlStream = aggregated.GetXmlStream())
             {
                 if (xmlStream != null && xmlStream.Length > 0L)
                 {
                     mementoClass = (AggregatedUserConfiguration.MementoClass)dataContractSerializer.ReadObject(xmlStream);
                 }
             }
         }
     }
     catch (SerializationException arg)
     {
         ExTraceGlobals.StorageTracer.TraceError <SerializationException>((long)this.GetHashCode(), "The aggregated configuration exists, but it could not be deserialized into a memento", arg);
     }
     catch (XmlException arg2)
     {
         ExTraceGlobals.StorageTracer.TraceError <XmlException>((long)this.GetHashCode(), "The aggregated configuration exists, but it could not be deserialized memento", arg2);
     }
     catch (ArgumentException arg3)
     {
         ExTraceGlobals.StorageTracer.TraceError <ArgumentException>((long)this.GetHashCode(), "The aggregated configuration exists, but it could not be deserialized into a memento", arg3);
     }
     if (mementoClass == null || 1 != mementoClass.Version)
     {
         mementoClass = (mementoClass ?? new AggregatedUserConfiguration.MementoClass());
     }
     mementoClass.Version           = 1;
     mementoClass.Parts             = (mementoClass.Parts ?? new Dictionary <UserConfigurationDescriptor.MementoClass, AggregatedUserConfigurationPart.MementoClass>());
     mementoClass.Pending           = (mementoClass.Pending ?? new List <AggregatedUserConfiguration.PendingUpdate>());
     mementoClass.ConcurrentUpdates = (mementoClass.ConcurrentUpdates ?? new HashSet <UserConfigurationDescriptor.MementoClass>());
     mementoClass.FailedToLoad      = (mementoClass.FailedToLoad ?? new HashSet <UserConfigurationDescriptor.MementoClass>());
     mementoClass.TypeBag           = (mementoClass.TypeBag ?? new Dictionary <string, SerializableDataBase>());
     return(mementoClass);
 }