IMetabaseCustomObject.CustomClass

Fore Syntax

CustomClass: IMetabaseCustomClass;

Fore.NET Syntax

CustomClass: Prognoz.Platform.Interop.Metabase.IMetabaseCustomClass;

Description

The CustomClass property determines object custom class.

Comments

Use the IMetabaseCustomObject.Extender property to determine a custom class container.

Fore Example

Executing the example requires that the repository contains the Resources object with the OBJ_RES identifier. There must be two icons: C:\Icon_small.ico and C:\Icon_large.ico in the file system.

Add links to the Metabase, Drawing, Io system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    Object: IMetabaseObject;
    CustomClassExtender: IMetabaseCustomExtender;
    CustClasses: IMetabaseCustomClasses;
    CustomClass: IMetabaseCustomClass;
    Operations: IMetabaseCustomClassOperations;
    Operation: IMetabaseCustomClassOperation;
    CreateInfo: IMetabaseObjectCreateInfo;
    Description: IMetabaseObjectDescriptor;
    ImgList, ImgList32: IGxImageList;
    Icon: IGxIcon;
    CustomObject: IMetabaseCustomObject;
Begin
    Mb := MetabaseClass.Active;
    
// Creating a custom class container
    CreateInfo := Mb.CreateCreateInfo;
    CreateInfo.ClassId := MetabaseObjectClass.KE_CLASS_CUSTOM_EXTENDER;
    CreateInfo.Name := 
"CUSTOM_EXTENDER";
    CreateInfo.Permanent := 
True;
    CreateInfo.Parent := Mb.Root;
    Description := Mb.CreateObject(CreateInfo);
    Object := Description.Edit;
    CustomClassExtender := Object 
As IMetabaseCustomExtender;
    ImgList := 
New GxImageList.Create;
    ImgList.Height := 
16;
    Icon := 
New GxIcon.CreateFromFile("C:\Icon_small.ico");
    ImgList.AddIcon(Icon);
    CustomClassExtender.SmallImages := ImgList;
    ImgList32 := 
New GxImageList.Create;
    ImgList32.Height := 
32;
    Icon := 
New GxIcon.CreateFromFile("C:\Icon_large.ico");
    ImgList32.AddIcon(Icon);
    CustomClassExtender.LargeImages := ImgList32;
    CustomClassExtender.IsShared := 
True;
    CustomClassExtender.Resource := Mb.ItemById(
"OBJ_RES").Bind As IResourceObject;
    CustomClassExtender.NameResource := 
"ID_CUSTOM_EXTENDER";
    
// Adding a custom class to the container
    CustClasses := CustomClassExtender.Classes;
    CustomClass := CustClasses.Add;
    CustomClass.Description := 
"Own class";
    CustomClass.ImageIndex := 
0;
    Operations := CustomClass.Operations;
    Operation := Operations.Add(
0);
    Operation.Name := 
"New method";
    Object.Save;
    
// Creating a custom class object
    CreateInfo.ClassId := CustomClass.ClassId;
    CreateInfo.Name := 
"Own class object";
    CreateInfo.Permanent := 
True;
    CreateInfo.Parent := Mb.Root;
    Description := Mb.CreateObject(CreateInfo);
    Object := Description.Edit;
    CustomObject := Object 
As IMetabaseCustomObject;
    CustomObject.Extender := CustomClassExtender;
    CustomObject.CustomClass := CustomClass;
    Object.Save;
End Sub UserProc;

After executing this example the custom classes container that contains one class is created. An object of this class is created in the repository.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.ForeIO;

Public Shared Sub Main(Params: StartParams);
Var
    Mb: IMetabase;
    Object: IMetabaseObject;
    CustomClassExtender: IMetabaseCustomExtender;
    CustClasses: IMetabaseCustomClasses;
    CustomClass: IMetabaseCustomClass;
    Operations: IMetabaseCustomClassOperations;
    Operation: IMetabaseCustomClassOperation;
    CreateInfo: IMetabaseObjectCreateInfo;
    Description: IMetabaseObjectDescriptor;
    ImgList, ImgList32: GxImageList;
    Icon: IGxIcon;
    CustomObject: IMetabaseCustomObject;
Begin
    Mb := Params.Metabase;
    // Creating a custom class container
    CreateInfo := Mb.CreateCreateInfo();
    CreateInfo.ClassId := MetabaseObjectClass.KE_CLASS_CUSTOM_EXTENDER As integer;
    CreateInfo.Name := "CUSTOM_EXTENDER";
    CreateInfo.Permanent := True;
    CreateInfo.Parent := Mb.Root;
    Description := Mb.CreateObject(CreateInfo);
    Object := Description.Edit();
    CustomClassExtender := Object As IMetabaseCustomExtender;
    ImgList := New GxImageList.Create();
    ImgList.Height := 16;
    Icon := New GxIcon.Create();
    Icon.CreateFromFile("C:\temp\CustomClass_ico\Icon_small.ico");
    ImgList.AddIcon(Icon);
    CustomClassExtender.SmallImages := ImgList;
    ImgList32 := New GxImageList.Create();
    ImgList32.Height := 32;
    Icon := New GxIcon.Create();
    Icon.CreateFromFile("C:\temp\CustomClass_ico\Icon_large.ico");
    ImgList32.AddIcon(Icon);
    CustomClassExtender.LargeImages := ImgList32;
    CustomClassExtender.IsShared := True;
    CustomClassExtender.Resource := Mb.ItemById["OBJ_RES"].Bind() As IResourceObject;
    CustomClassExtender.NameResource := "ID_CUSTOM_EXTENDER";
    // Adding a custom class to the container
    CustClasses := CustomClassExtender.Classes;
    CustomClass := CustClasses.Add();
    CustomClass.Description := "Own class";
    CustomClass.ImageIndex := 0;
    Operations := CustomClass.Operations;
    Operation := Operations.Add(0);
    Operation.Name := "New method";
    Object.Save();
    // Creating a custom class object
    CreateInfo.ClassId := CustomClass.ClassId;
    CreateInfo.Name := "Own class object";
    CreateInfo.Permanent := True;
    CreateInfo.Parent := Mb.Root;
    Description := Mb.CreateObject(CreateInfo);
    Object := Description.Edit();
    CustomObject := Object As IMetabaseCustomObject;
    CustomObject.Extender := CustomClassExtender;
    CustomObject.CustomClass := CustomClass;
    Object.Save();
End Sub;

See also:

IMetabaseCustomObject