.NET objects of development environment are: .NET assembly, .NET form and .NET unit. All these objects are the objects of repository, the following object classes should be used to create them:
MetabaseObjectClass.KE_CLASS_NETASSEMBLY - .NET assembly.
MetabaseObjectClass.KE_CLASS_NETFORM - .NET form.
MetabaseObjectClass.KE_CLASS_NETMODULE - .NET unit.
The existing .NET assembly should be specified as the parent object at creation of .NET forms and .NET units. Number of methods is implemented for preliminary configuration of .NET objects after their creation:
InitAssembly is a basic setting of.NET assembly.
Example of .NET assembly creation:
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
Assembly: IMetabaseObject;
NETAssembly: IForeNETAssembly;
Begin
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_NETASSEMBLY;
CrInfo.Name := "New assembly";
CrInfo.Id := "NewAssembly";
CrInfo.Permanent := True;
CrInfo.Parent := MB.Root;
Assembly := MB.CreateObject(CrInfo).Bind;
NETAssembly := Assembly As IForeNETAssembly;
NETAssembly.InitAssembly;
Example of .NET form creation:
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
Begin
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_NETFORM;
CrInfo.Name := "New form";
CrInfo.Id := "NewForm";
CrInfo.Permanent := True;
CrInfo.Parent := MB.ItemById("NewAssembly");
MB.CreateObject(CrInfo);
Example of .NET unit creation:
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
Begin
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_NETMODULE;
CrInfo.Name := "New unit";
CrInfo.Id := "NewModule";
CrInfo.Permanent := True;
CrInfo.Parent := MB.ItemById("NewAssembly");
MB.CreateObject(CrInfo);
Implementation of custom applications is performed in required .NET objects after their creation and configuration. The Fore.NET language is used to write the code. Special interfaces are implemented in this assembly to use .NET objects in regular Fore forms/units. For more details see in the Using the Fore.NET in Fore section.
The number of methods is implemented to start .NET assemblies/forms from code in Fore:
IForeNETAssembly.Run is a start of .NET assembly to execute. Executing the example starts the object that is set as the start object of .NET assembly. The startup object is set at the Parameters of assembly tab in the links configuration window of .NET assembly.
IForeNETRuntimeForm.Show is an opening of .NET form.
IForeNETRuntimeForm.ShowDialog is an opening of .NET form, modal relative to specified window.
Example of .NET assembly startup from code in Fore:
Var
MB: IMetabase;
NETAssembly: IForeNETAssembly;
Begin
MB := MetabaseClass.Active;
NETAssembly := MB.ItemById("NewAssembly").Bind As IForeNETAssembly;
NETAssembly.Run;
Example of .NET form startup from code in Fore:
Var
MB: IMetabase;
Run: IForeNETRuntime;
Asm: IForeNETRuntimeAssembly;
RuntimeForm: IForeNETRuntimeForm;
Begin
MB := MetabaseClass.Active;
Run := ForeNETAssemblyClass.Runtime;
Asm := Run.Assembly(MB.ItemById("NewAssembly").Bind As IForeNETAssembly);
RuntimeForm := Asm.Form("NewAssembly.NewForm");
RuntimeForm.Show;
See also: