public void SaveTo(SaveEntryFolder parentFolder, IArchiveContext archiveContext)
        {
            int             entryCount = this._containerType == ContainerType.Dictionary ? this._elementCount * 2 : this._elementCount;
            SaveEntryFolder folder     = archiveContext.CreateFolder(parentFolder, new FolderId(this.ObjectId, SaveFolderExtension.Container), entryCount);

            for (int id = 0; id < this._elementCount; ++id)
            {
                ElementSaveData elementSaveData = this._values[id];
                BinaryWriter    binaryWriter1   = BinaryWriterFactory.GetBinaryWriter();
                BinaryWriter    binaryWriter2   = binaryWriter1;
                elementSaveData.SaveTo((IWriter)binaryWriter2);
                folder.CreateEntry(new EntryId(id, SaveEntryExtension.Value)).FillFrom(binaryWriter1);
                BinaryWriterFactory.ReleaseBinaryWriter(binaryWriter1);
                if (this._containerType == ContainerType.Dictionary)
                {
                    ElementSaveData key           = this._keys[id];
                    BinaryWriter    binaryWriter3 = BinaryWriterFactory.GetBinaryWriter();
                    BinaryWriter    binaryWriter4 = binaryWriter3;
                    key.SaveTo((IWriter)binaryWriter4);
                    folder.CreateEntry(new EntryId(id, SaveEntryExtension.Key)).FillFrom(binaryWriter3);
                    BinaryWriterFactory.ReleaseBinaryWriter(binaryWriter3);
                }
            }
            foreach (ObjectSaveData childStruct in this._childStructs)
            {
                childStruct.SaveTo(folder, archiveContext);
            }
        }
 public void CollectChildren()
 {
     this._keys   = new ElementSaveData[this._elementCount];
     this._values = new ElementSaveData[this._elementCount];
     if (this._containerType == ContainerType.Dictionary)
     {
         IDictionary target = (IDictionary)this.Target;
         int         index  = 0;
         foreach (DictionaryEntry dictionaryEntry in target)
         {
             object          key = dictionaryEntry.Key;
             object          obj = dictionaryEntry.Value;
             ElementSaveData elementSaveData1 = new ElementSaveData(this, key, index);
             ElementSaveData elementSaveData2 = new ElementSaveData(this, obj, this._elementCount + index);
             this._keys[index]   = elementSaveData1;
             this._values[index] = elementSaveData2;
             ++index;
         }
     }
     else if (this._containerType == ContainerType.List)
     {
         IList target = (IList)this.Target;
         for (int index = 0; index < this._elementCount; ++index)
         {
             ElementSaveData elementSaveData = new ElementSaveData(this, target[index], index);
             this._values[index] = elementSaveData;
         }
     }
     else if (this._containerType == ContainerType.Queue)
     {
         ICollection target = (ICollection)this.Target;
         int         index  = 0;
         foreach (object obj in (IEnumerable)target)
         {
             ElementSaveData elementSaveData = new ElementSaveData(this, obj, index);
             this._values[index] = elementSaveData;
             ++index;
         }
     }
     else
     {
         if (this._containerType != ContainerType.Array)
         {
             return;
         }
         Array target = (Array)this.Target;
         for (int index = 0; index < this._elementCount; ++index)
         {
             ElementSaveData elementSaveData = new ElementSaveData(this, target.GetValue(index), index);
             this._values[index] = elementSaveData;
         }
     }
 }
 public IEnumerable <ElementSaveData> GetChildElementSaveDatas()
 {
     for (int i = 0; i < this._elementCount; ++i)
     {
         ElementSaveData key   = this._keys[i];
         ElementSaveData value = this._values[i];
         if (key != null)
         {
             yield return(key);
         }
         if (value != null)
         {
             yield return(value);
         }
         value = (ElementSaveData)null;
     }
 }