The principle of ERPCore (two)

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

The program is initialized, it creates the main form

procedure TMain.FormCreate(Sender: TObject); begin TObjFactoryEx.Create([IMainForm,IFormMgr],self); SetSysSkin(dxSkinController); if not LoadSysModule then exit; LoadUserModule; if not Sys.Login.Login then begin Application.ShowMainForm:=False; Application.Terminate; end; Sys.ERPInit.InitSYS; Sys.ERPInit.InitMenu(dxBarManager); CloseSplash; BringToFront; End;

The main form is created to do the following things

1 examples of factory, will form the main interface of Self and IMainForm, IFormMgr binding,

So when access to the two interface is called the main form in the realization of the code, the factory will be in the later on

2 set up the system of skin

3 loading system module and user module, the module of management here.

4 landing system

5 system initialization (and user)


First talk about the interface, all start from here, to talk about some beginners do not understand well.

There is a section of code in SysModuleMgr.pas


procedure TTangramModule.UnInstall; var Reg:IRegistry; begin if FModuleCls<>nil then begin Reg:=SysService as IRegistry; FModuleCls.UnRegisterModule(Reg); end; end;

Where SysService is the TSysService object

TSysService=Class(TObject,IInterface,ISysService)

No inheritance relationship with IRegister interface, can why can as?

This is because the TSysService to implement the IInterface interface


function TSysService.QueryInterface(const IID: TGUID; out Obj): HResult; var aFactory:TFactory; begin Result:=E_NOINTERFACE; if self.GetInterface(IID,Obj) then Result:=S_OK else begin aFactory:=FactoryManager.FindFactory(IID); if Assigned(aFactory) then begin aFactory.prepare(FParam); Result:=aFactory.GetIntf(IID,Obj); end; end; end;

Query interface, will search through the GUID first, when the search search will not to plant management

In this framework, the interface will be the first registered to the factory, which is why any framework module can call to a different module interface

While the as operation will call interface to query QueryInterface

So there are SysService as IRegistry this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Ken at January 11, 2014 - 10:54 PM