/// <summary> /// Save an object to a SaveInfo. /// </summary> /// <param name="source">The source object to save.</param> /// <param name="info">The info to save the object to.</param> /// <param name="scanner">The MemberScanner to use to save the object.</param> public static void SaveObject(Object source, SaveInfo info, MemberScanner scanner) { foreach (MemberWrapper wrapper in scanner.getMatchingMembers(source.GetType())) { info.AddReflectedValue(wrapper.getWrappedName(), wrapper.getValue(source, null), wrapper.getWrappedType()); } }
/// <summary> /// Write an object to the stream. /// </summary> /// <param name="identifier">The ObjectIdentifier of the object to write.</param> /// <param name="info">The info for the object to write.</param> protected void writeObject(ObjectIdentifier identifier, SaveInfo info) { headerWriter.writeHeader(identifier, info.Version); foreach (SaveEntry entry in info.saveEntryIterator()) { valueWriters.writeValue(entry); } footerWriter.writeFooter(identifier); }
/// <summary> /// Save an object. This will return the object id for the Saveable /// passed in. If this saveable was already found it will return the /// previously assigned id, otherwise it will make a new one. If save is /// null then this function will return NullObject; /// </summary> /// <param name="save">The object to identify and save.</param> /// <returns>See description.</returns> internal long saveObject(Saveable save) { if (save == null) { return(NullObject); } if (identiferMap.ContainsKey(save)) { return(identiferMap[save].ObjectID); } else { SaveInfo info = checkOutSaveInfo(); ObjectIdentifier identifier = new ObjectIdentifier(currentObjectID++, save, save.GetType()); identiferMap.Add(save, identifier); save.getInfo(info); writeObject(identifier, info); checkInSaveInfo(info); return(identifier.ObjectID); } }
/// <summary> /// Check in a SaveInfo. /// </summary> /// <param name="info">The info to check in.</param> private void checkInSaveInfo(SaveInfo info) { info.reset(); pooledInfos.Push(info); }
/// <summary> /// Save an object to a SaveInfo using the default scanner. /// </summary> /// <param name="source">The source object to save.</param> /// <param name="info">The info to save the object to.</param> public static void SaveObject(Object source, SaveInfo info) { SaveObject(source, info, DefaultScanner); }