IMetabaseCustomObjectReferences.Add

Syntax

Add(Object: IMetabaseObjectDescriptor): IMetabaseCustomObjectReference;

Parameters

Object - an object of the repository on which the object should depend.

Description

The Add method adds a dependency in the collection.

Fore Example

Executing the example requires that the repository contains a custom class object with the OBJ_CUSTOM identifier and an object with the OBJ_REF identifier.

Add a link to the Metabase system assembly.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Mb: IMetabase;
    Object: IMetabaseObject;
    CustomObject: IMetabaseCustomObject;
    Writer: IMetabaseCustomObjectWriter;
    References: IMetabaseCustomObjectReferences;
Begin
    Mb := MetabaseClass.Active;
    Object := Mb.ItemById(
"OBJ_CUSTOM").Edit;
    CustomObject := Object 
As IMetabaseCustomObject;
    Writer := CustomObject.CreateWriter;
    References := Writer.References;
    References.Add(Mb.ItemById(
"OBJ_REF"));
    Writer.Save;
    Object.Save;
End Sub Button1OnClick;

After executing this example the OBJ_REF object is added to the list of objects on which OBJ_CUSTOM depends.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example. Use Fore.NET analogs instead of Fore components.

Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
    Mb: IMetabase;
    Object: IMetabaseObject;
    CustomObject: IMetabaseCustomObject;
    Writer: IMetabaseCustomObjectWriter;
    References: IMetabaseCustomObjectReferences;
Begin
    Mb := Self.Metabase;
    Object := Mb.ItemById[
"OBJ_CUSTOM"].Edit();
    CustomObject := Object 
As IMetabaseCustomObject;
    Writer := CustomObject.CreateWriter();
    References := Writer.References;
    References.Add(Mb.ItemById[
"OBJ_REF"]);
    Writer.Save();
    Object.Save();
End Sub;

See also:

IMetabaseCustomObjectReferences