Last few years, there is a rise in open-source Delphi projects on GitHub. Many tech companies which utilize Delphi is publishing their code to GitHub to share their different solution for different problems in the software development business.
InstantObjects – this is the integrated framework for developing an object-oriented solution in Delphi. This framework enables the creation of applications based on persistent business objects. A business object is an object that has a set of properties and values, operations, and connections to other business objects. Business objects include business data and model business behavior.
InstantObject framework simplifies the process of realizing ideas into products, it shortens time-to-market and helps keep business focus. Since it is easy to integrate with the Delphi IDE, you can create business applications with it in no time.
InstantObjects offers:
- Model realization in the Delphi IDE via integrated two-way tools.
- Object persistence in the most common relational databases or flat XML-based files.
- Object presentation via standard data-aware controls.
- Serialization/Deserialization of object using delphi-neon library
When you install the framework from the GetIt Package Manager, you will get several demo applications for you to learn more about the use cases of the framework. And you can find more information about the framework on its wiki page.
program IOConsoleDemo;
{$APPTYPE CONSOLE}
uses
SysUtils,
Model in 'Model.pas',
InstantPersistence,
InstantXML;
{$R *.mdr} {Model}
var
ApplicationPath : string;
Connection : TXMLFilesAccessor;
Connector : TInstantXMLConnector;
SimpleClass : TSimpleClass;
Id : string;
i : integer;
begin
ApplicationPath := ExtractFilePath(ParamStr(0));
Try
//In every application the mdr file is normally included into the applications
//by InstantObjects.
//You can generate it at run-time calling, for example:
//CreateInstantModel;
//You read it from disk, for example:
//InstantModel.LoadFromFile(ApplicationPath+'MinimalModel.xml');
//Connect to database
Connection := nil;
Connector := nil;
Try
Connection := TXMLFilesAccessor.Create(nil);
Connection.RootFolder := ApplicationPath+'XMLStorage';
Connector := TInstantXMLConnector.Create(nil);
Connector.Connection := Connection;
Connector.LoginPrompt := False;
Connector.IsDefault := True;
WriteLn('Building Database structure');
Connector.BuildDatabase;
WriteLn('Connecting to Database.');
Connector.Connect;
for i := 0 to 100 do
begin
WriteLn('Storing Object.');
SimpleClass := TSimpleClass.Create;
Try
SimpleClass.StringProperty := IntToStr(Random(MaxInt));
SimpleClass.Store;
Id := SimpleClass.Id;
Finally
SimpleClass.Free;
End;
WriteLn('Retrieving and changing Object.');
SimpleClass := TSimpleClass.Retrieve(Id);
Try
SimpleClass.StringProperty := IntToStr(Random(MaxInt));
SimpleClass.Store;
Finally
SimpleClass.Free;
End;
(*
WriteLn('Retrieving and deleting Object.');
SimpleClass := TSimpleClass.Retrieve(Id);
Try
SimpleClass.Dispose;
Finally
SimpleClass.Free;
End;
*)
end;
WriteLn('Disconnecting from Database.');
Connector.Disconnect;
Finally
Connector.Free;
Connection.Free;
End;
WriteLn('Done!');
Except
on E: Exception do WriteLn(E.Message);
End;
end.