public Amf3Object(Amf3ClassDef classDef) { if (classDef == null) throw new ArgumentNullException("classDef"); ClassDef = classDef; Properties = new Dictionary<string, object>(); }
public void WriteObjectHeader(Amf3ClassDef classDef) { Write(Amf3TypeCode.Object); TypelessWrite(classDef); StoreObject(null); }
public void TypelessWrite(Amf3ClassDef classDef) { // have we written this class before with this writer? if (classDef.mWriter == this) { // use the cached id in the class definition TypelessWrite((classDef.mId << 2) | 1); return; } int index; if (classDefTable.TryGetValue(classDef, out index)) { // store class id inside of class def for this writer classDef.mWriter = this; classDef.mId = index; TypelessWrite((index << 2) | 1); } else { // store class id inside of class def for this writer classDef.mWriter = this; classDef.mId = classDefTable.Count; // store class reference in lookup table classDefTable[classDef] = classDef.mId; Amf3Object.Flags flags = Amf3Object.Flags.Inline | Amf3Object.Flags.InlineClassDef; if (classDef.Externalizable) flags |= Amf3Object.Flags.Externalizable; if (classDef.Dynamic) flags |= Amf3Object.Flags.Dynamic; TypelessWrite((int)flags | (classDef.Properties.Count << 4)); TypelessWrite(classDef.Name); foreach (string i in classDef.Properties) { TypelessWrite(i); } } }