GetMetabaseObjectClass(ClassId: Integer): MetabaseObjectClass;
ClassId - numerical identifier of a class.
The GetMetabaseObjectClass method returns a class of the object that is implemented by the MetabaseObjectClass enumeration type by the numeric value of the class identifier.
This method is used if it is necessary to work with an object class as with an object of the MetabaseObjectClass type but only numerical identifier of a class is available, foe example as in the case with custom classes.
Executing the example requires a form with the Button1 button and the MetabaseOpenDialog component named MetabaseOpenDialog1. Classes with the MyClass1 and the MyClass2 identifiers are created in the custom class container of the object.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
MB: IMetabase;
CustExtender: IMetabaseCustomExtender;
Classes: IMetabaseCustomClasses;
ClassFilter1, ClassFilter2: IMetabaseDialogClassFilter;
CombiFilter: IMetabaseDialogCombiFilter;
Begin
MB := MetabaseClass.Active;
//Get container of custom classes
CustExtender := MB.SpecialObject(MetabaseSpecialObject.CustomExtender).Bind As IMetabaseCustomExtender;
//Get a list of custom classes
Classes := CustExtender.Classes;
//Create filters by objects classes
ClassFilter1 := New MetabaseDialogClassFilter.Create;
ClassFilter2 := New MetabaseDialogClassFilter.Create;
//Combined filter
CombiFilter := New MetabaseDialogCombiFilter.Create;
//Set classes of filtered objects
ClassFilter1.ObjectClass :=
MetabaseClass.GetMetabaseObjectClass(Classes.FindById("MyClass1").ClassId);
ClassFilter2.ObjectClass :=
MetabaseClass.GetMetabaseObjectClass(Classes.FindById("MyClass2").ClassId);
//Union in combined filter
CombiFilter.Filters.AddFilter(ClassFilter1);
CombiFilter.Filters.AddFilter(ClassFilter2);
//Attach filter in component
MetabaseOpenDialog1.Filters.AddFilter(CombiFilter);
MetabaseOpenDialog1.Execute(Self);
End Sub Button1OnClick;
After executing the example while pressing the button a combined filter by objects classes is installed for the MetabaseOpenDialog1 component. A combined filter includes two filters by custom classes of objects. Use the GetMetabaseObjectClass method to specify a custom class in a filter. After dialog initialization only objects of specified custom classes are available for the selection.
See also: