LoadForm: IForeNETForm;
The LoadForm method loads and saves the .NET form to the repository.
The method loads and saves the .NET form according to the parameters, specified in the CreateInfo property. The form 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 form, the exception is generated.
Executing this example requires the TestForm.ppnform file 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:\TestForm.ppnform", 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.LoadForm;
End Sub UserProc;
On executing this example the .NET form is loaded from the specified file. .The .NET form is saved in the specified .NET assembly of repository. If the given .NET assembly contains an object having same identifier with the loaded .NET form, the identifier of .NET form will be changed before loading.
NOTE. If the identifier of .NET form is changed at loading, the name of the class corresponding to this .NET form should be modified to make the .NET form operative.
See also: