2021年12月13日 星期一

Delphi object bin­ary Serializing TWinControl Tpanel File save an object to a file in Delphi dfm

 save an object to a file in Delphi

http://robstechcorner.blogspot.com/2009/09/so-what-is-rtti-rtti-is-acronym-for-run.html

Delphi 2010 RTTI - The basics
Using Attributes and TCustomAttribute descendants
Exploring TRTTIType in depth
Introduction to TValue
Exploring TRttiMember Descendants in depth (Part I) Properties and Fields
Why I call TRttiContext.Create() and TRttiContext.Free()
Exploring TRttiMember Descendants in depth (Part II) Methods
TValue in Depth
INI persistence the RTTI way
Xml Serialization - Basic Usage
Xml Serialization - Control via Attributes
Attributes: Practical Example- Object to Client Dataset
Types by Package... Dynamic plug-in systems.

http://robstechcorner.blogspot.com/2009/10/xml-serialization-basic-usage.html
robstechcorner https://code.google.com/archive/p/robstechcorner/source

 Xml Serialization - Basic Usage http://robstechcorner.blogspot.com/2009/10/xml-serialization-basic-usage.html

// Method 1:
var
 o : TypeIWantToSerailze;
 s : TXmlTypeSerializer;
 x : TXmlDocument;
 v : TValue;
begin
  s := TXmlTypeSerializer.create(TypeInfo(o));
  x := TXmlDocument.Create(Self); // NEVER PASS NIL!!!
  s.Serialize(x,o);
  x.SaveToFile('FileName.txt');
  v := s.Deserialize(x);
  o := v.AsType<TypeIWantToSerailze>;
  x.free;
  s.free;
end;

// Method 2:
var
 o : TypeIWantToSerailze;
 s : TXmlSerializer<TypeIWantToSerailze>;
 x : TXmlDocument;
begin
  s := TXmlTypeSerializer<TypeIWantToSerailze>.create;
  x := TXmlDocument.Create(Self); // NEVER PASS NIL!!!
  s.Serialize(x,o);
  x.SaveToFile('FileName.txt');
  o := s.Deserialize(x);
  x.free;
  s.free;
end;

https://pavkam.dev/
 
https://stackoverflow.com/questions/2657502/practical-usage-for-delphis-new-rtti-attributes-values/2657604#2657604
The extended RTTI works like Reflection in .NET. It gives you access to your internal application structure information. You can access class properties, methods etc.. at runtime, at extent you could not do it before.

Some ways of using it:

    Serialization / Deserialization of classes to XML or other media
    Mapping of objects to databases. ORM.
    Cloning of objects
    Dynamic invocation of methods
    "Scanning" of object at runtime and acting according to that.
    Easier development of "plugin" type systems

There is probably a lot of scenarios where it would be beneficial to use it. In short it adds dynamic aspect to your application. Your product is able to do some things at runtime, and more efficiently, than designing everything at designtime. It is not a silver bullet and a lot of people may never use it. But some design patterns or some problems just cannot be solved (at least not in efficient way) without the use of the new RTTI

https://martinfowler.com/articles/injection.html
https://en.wikipedia.org/wiki/Dependency_injection
https://code.google.com/archive/redirect/a/code.google.com/p/delphi-spring-framework?movedTo=https:%2F%2Fbitbucket.org%2Fsglienke%2Fspring4d
https://martinfowler.com/articles/injection.html#ConstructorVersusSetterInjection
https://code.google.com/archive/redirect/a/code.google.com/p/delphi-spring-framework?movedTo=https:%2F%2Fbitbucket.org%2Fsglienke%2Fspring4d
https://delphihaven.wordpress.com/2009/09/02/d2010-rtti-and-active-scripting/

Delphi Haven
Just another Delphi programming port of call on the internet
My book

[Delphi XE2 Foundations]
Some code

    AutoCorrect Components v1.0.3
    CCR Exif v1.5.1
    Generic IDispatch Proxy Classes for Active Scripting (Delphi 2010+)
    Hunspell Wrapper
    Theming Owner-Drawn Tabs
 
Something new for something old: Delphi 2010’s RTTI and Active Scripting

https://theroadtodelphi.com/2009/10/27/convert-string-to-enum-using-delphi-prism/
http://www.malcolmgroves.com/blog/?p=476

RTTI and Attributes in Delphi 2010
How to serialize Delphi object
https://blog.dragonsoft.us/2008/04/21/how-to-serialize-delphi-object/

https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Working_with_RTTI
https://docwiki.embarcadero.com/Libraries/XE2/en/Main_Page

serialize Delphi object  bin­ary  seri­al­iz­a­tion

https://github.com/codejanovic/Delphi-Serialization
https://www.codeproject.com/Articles/1060345/DFM-serialization-in-depth
https://docwiki.embarcadero.com/RADStudio/Sydney/en/Serializing_User_Objects
https://coderedirect.com/questions/441027/binding-an-xml-node-to-a-tree-view-node

https://stackoverflow.com/questions/8782518/getting-the-size-of-a-class-or-object-in-the-same-format-as-a-file-size

https://stackoverflow.com/questions/65171574/how-to-calculate-delphi-class-size-using-tmemorystream-size

A case of using delphiXE RTTI to dynamically obtain information at runtime and obtain RttiType information of a TComponent class or TObject class
https://www.codetd.com/en/article/12146232


Delphi object  bin­ary  Serializing TWinControl  Tpanel File

沒有留言: