TValue.Make(nil, MapType.Handle, Result) Create an Empty Record, Value Type, etc. TXmlCustomTypeSerializer.DeSerializeValue changeĬlass is null and before control > 1 add codeįunction TXmlCustomTypeSerializer.DeSerializeValue(Node: IXMLNode MapType: TRttiType Map: TMemberMap): TValue I will show how to customize the behavior using attributes in a future post. Hopefully this covers enough of how to use this to get you started. The project that shows how to use this object.Ĭurrent output of the XML file, notice the Date, it's something I want to change, if you check the roadmap in the xmlserial.pas source. Procedure TPerson.Save(FileName: String) LDoc := TXmlDocument.Create(lOwner) // will be freed with lOwner.Free LOwner := TComponent.Create(nil) // Required to make TXmlDocument work! Result := FFirstName + ' ' + FMiddleName + ' ' + FLastName Ĭlass function TPerson.Load(FileName: String): TPerson Property Birthday : TDateTime read FBirthday write FBirthday Ĭlass function Load(FileName : String) : TPerson Property FullName : String read GetFullName Property MiddleName : String read FMiddleName write FMiddleName Property LastName : String read FLastName write FLastName Property FirstName : String read FFirstName write FFirstName X := TXmlDocument.Create(Self) // NEVER PASS NIL!!!Īnd here is the full code showing how to do this using the generic version. S := TXmlTypeSerializer.create(TypeInfo(o)) There are two ways to work with the Xml Serialization, one depends on a Pointer to the Type Information, the other uses Generics to get it form the type specified as a parameter. The complete goals of what I want to accomplish with XmlSerial.pas look at the source code, I detailed out what still needs to be done. NET using Delphi Prism and Win32 using Delphi 2010. NET Xml Serialization with the goal of having a set of objects that can serialize in. This was done to mimic the behavior found in the. This class has been built to serialize any public and published property or Field. I think anycodings_serialization it's due to inheritance.This post relates to XmlSerial.pas which provides XML serialization and de-serialization using the new RTTI in Delphi 2010. So my code is working when my class doesn't anycodings_serialization inherit from any another class, if i declare anycodings_serialization it like this : TContainer: classīut when i do like above, with : TContainer: class(TGraphicControl) JSONString := m.Marshal(Container).Format Property ContainerType: string read FContainerType write FContainerType Ĭontainer.FContainerName := 'Container001' Property ContainerName: string read FContainerName write FContainerName Test to customize the property name : works I wrote this class : TContainer: class(TGraphicControl) I'm trying to learn how to serialize objects anycodings_serialization with Delphi 10.3.3 Rio using this units : anycodings_serialization REST.JsonReflect and
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |