IForeNETSerializerLoader.LoadModule

Syntax

LoadModule: IForeNETModule;

Description

The LoadModule method loads and saves the .NET unit to the repository.

Comments

The method loads and saves the .NET unit according to the parameters specified in the CreateInfo property. The module is saved within .NET assembly, specified in the Assembly property. If the assembly already contains an object , identifier of which corresponds to identifier of loaded .NET unit, the exception is generated.

Example

Executing this example requires the TestModule.ppnmodule in the root directory of disk C. This file contains the saved .NET form of the platform. The current repository contains a .NET assembly with the TestAssembly identifier.

Sub UserProc;
Var
    MB: IMetabase;
    NETAsm: IMetabaseObjectDescriptor;
    Fs: IForeNETSerializer;
    Fsl: IForeNETSerializerLoader;
    Id: String;
Begin
    MB := MetabaseClass.Active;
    NETAsm := MB.ItemById("TestAssembly");
    Fs := New ForeNETSerializer.Create;
    Fsl := Fs.CreateLoaderFromFile("c:\TestModule.ppnmodule", MB);
    Id := Fsl.CreateInfo.Id;
    If MB.ItemByIdNamespace(Id, NETAsm.Key) <> Null Then
        Fsl.CreateInfo.Id := MB.GenerateId(Id, NETAsm.Key);
        Fsl.CreateInfo.Name := Fsl.CreateInfo.Name + "_Copy";
    End If;
    Fsl.Assembly := NETAsm.Bind As IForeNETAssembly;
    Fsl.CreateInfo.Parent := NETAsm;
    Fsl.LoadModule;
End Sub UserProc;

On executing the example the .NET unit is loaded from the specified file. The .NET unit is saved in the specified .NET assembly of repository. If the given .NET assembly contains an object having same identifier with the loaded .NET unit, the identifier of .NET unit is changed before loading.

See also:

IForeNETSerializerLoader