public flash.utils.Dictionary ReadDictionary() { // get entry count int num = ReadInteger(); if ((num & 1) == 0) { return((flash.utils.Dictionary)GetTableEntry(objectTable, num >> 1)); } num >>= 1; // weak keys? bool weakKeys = ReadByte() != 0; // create dictionary var dict = new flash.utils.Dictionary(weakKeys); objectTable.Add(dict); // read entries for (int i = 0; i < num; i++) { // read key object key = ReadNextObject(); // read value object value = ReadNextObject(); // store in dictionary dict[key] = value; } return(dict); }
public void TypelessWrite(flash.utils.Dictionary dict) { if (TrackArrayReferences) { if (CheckObjectTable(dict)) { return; } StoreObject(dict); } else { StoreObject(null); } // write byte array length TypelessWrite((dict.length << 1) | 1); // no weak keys for now TypelessWrite((byte)0); // write dictionary key value pairs int count = 0; foreach (var kvp in dict) { Write(kvp.Key); Write(kvp.Value); count++; } if (count != dict.length) { throw new InvalidOperationException("flash.utils.Dictionary count does not match expected length"); } }
public void Write(flash.utils.Dictionary dict) { Write(Amf3TypeCode.Dictionary); TypelessWrite(dict); }