Work with .NET Objects of Development Environment

Creation of .NET Objects

.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:

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:

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);

Control on .NET Assemblies and .NET Forms

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:

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:

Introduction