pascalabcnet/InstallerSamples/StandardUnits/PABCSystem/Serialization/SerializationGraph.pas
2022-04-18 21:34:18 +03:00

19 lines
762 B
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Сериализация объектов
// Можно сериализовать только объекты, помеченные атрибутом [Serializable]
// Внешние Serialize, Deserialize позволяют сохранить в файле - восстановить
// один объект (один граф объектов с данным корнем)
type
[Serializable]
Node = auto class
x: integer;
next: Node;
end;
const fname = 'a.dat';
begin
var m := new Node(5,new Node(3,new Node(4,nil))); // Связный список
Serialize(fname,m); // Сериализуем объект в файл
var m1 := Deserialize(fname) as Node; // Десериализуем из файла
Print(m1);
end.