private T DeserialiseNewObject <T>(MfcClass mfcClass) where T : MfcObject { MfcObject newObject = mfcClass.CreateNewObject <MfcObject>(); _loadedObjects.Add(newObject); newObject.Deserialise(this); return((T)newObject); }
public void SerialiseObject(MfcObject mfcObject) { if (mfcObject == null) { _stream.Write((ushort)NullTag); return; } int prevObjectIndex = _loadedObjects.IndexOf(mfcObject); if (prevObjectIndex >= 0) { // We have already serialised this object and do not need to do so again if (prevObjectIndex >= BigObjectTag) { throw new NotImplementedException("Object count >= 0x7fff not yet supported"); } _stream.Write((ushort)prevObjectIndex); return; } // A new object, possibly with a new class _loadedObjects.Add(mfcObject); MfcClass mfcClass = _classRegistry.GetMfcClass(mfcObject.GetType()); int prevClassIndex = _loadedClasses.IndexOf(mfcClass); if (prevClassIndex <= 0) { // A new class _loadedClasses.Add(mfcClass); _stream.Write((ushort)NewClassTag); _stream.Write((ushort)mfcClass.SchemaVersion); _stream.Write((ushort)mfcClass.Name.Length); _stream.WriteAsciiString(mfcClass.Name); } else { // A previously written class _stream.Write((ushort)(prevClassIndex | ClassTag)); } mfcObject.Serialise(this); }
/// <summary> /// Serialises an object without writing out the header. /// </summary> public void SerialiseObjectNoHeader(MfcObject mfcObject) { _loadedObjects.Add(mfcObject); mfcObject.Serialise(this); }