AddWithOwner(Object: IMetabaseObjectDescriptor;
Owner: IMetabaseObjectDescriptor
): IMetabaseCustomObjectReference;
AddWithOwner(Object: Prognoz.Platform.Interop.Metabase.IMetabaseObjectDescriptor;
Owner: Prognoz.Platform.Interop.Metabase.IMetabaseObjectDescriptor
): Prognoz.Platform.Interop.Metabase.IMetabaseCustomObjectReference;
Object. Repository object, on which custom class object depends.
Owner. Repository object that is a parent for the object specified in the Object parameter.
The AddWithOwner method adds dependency from object and its parent.
To add dependency only from object, use the IMetabaseCustomObjectReferences.Add method.
Executing the example requires that the repository contains a custom class object with the CUSTOM_CLASS_OBJ identifier, an object with the MDM_HIE_INDICATOR_D identifier that is a child object for object with the MDM_INDICATOR_D identifier.
Add a link to the Metabase system assembly.
Sub UserProc;
Var
pMb: IMetabase;
pObject: IMetabaseObject;
pCustomObject: IMetabaseCustomObject;
pWriter: IMetabaseCustomObjectWriter;
pReferences: IMetabaseCustomObjectReferences;
pRef: IMetabaseCustomObjectReference;
Begin
// Get current repository
pMb := MetabaseClass.Active;
// Get custom class object
pObject := pMb.ItemById("CUSTOM_CLASS_OBJ").Edit;
pCustomObject := pObject As IMetabaseCustomObject;
// Create an object that enables writing data to custom class object
pWriter := pCustomObject.CreateWriter;
// Get collection of object dependencies
pReferences := pWriter.References;
// Clear collection of object dependencies
pReferences.Clear;
// Add the MDM_HIE_INDICATOR_D object with its parent MDM_INDICATOR_D
pRef := pReferences.AddWithOwner(pMb.ItemById("MDM_HIE_INDICATOR_D"), pMb.ItemById("MDM_INDICATOR_D"));
// Output information about this to console window
Debug.WriteLine("Object '" + pRef.Object.Id + "' with parent '" + pRef.Owner.Id + "' are added");
// Save changes
pWriter.Save;
pObject.Save;
End Sub UserProc;
After executing the example the dependency from the MDM_HIE_INDICATOR_D object and its parent is added for custom class object.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Public Shared Sub Main(Params: StartParams);
Var
pMb: IMetabase;
pObject: IMetabaseObject;
pCustomObject: IMetabaseCustomObject;
pWriter: IMetabaseCustomObjectWriter;
pReferences: IMetabaseCustomObjectReferences;
pRef: IMetabaseCustomObjectReference;
Begin
// Get current repository
pMb := Params.Metabase;
// Get custom class object
pObject := pMb.ItemById["CUSTOM_CLASS_OBJ"].Edit();
pCustomObject := pObject As IMetabaseCustomObject;
// Create an object that enables writing data to custom class object
pWriter := pCustomObject.CreateWriter();
// Get collection of object dependencies
pReferences := pWriter.References;
// Clear collection of object dependencies
pReferences.Clear();
// Add the MDM_HIE_INDICATOR_D object with its parent MDM_INDICATOR_D
pRef := pReferences.AddWithOwner(pMb.ItemById["MDM_HIE_INDICATOR_D"], pMb.ItemById["MDM_INDICATOR_D"]);
// Output information about this to console window
System.Diagnostics.Debug.WriteLine("Object '" + pRef.Object.Id + "' with parent '" + pRef.Owner.Id + "' are added");
// Save changes
pWriter.Save();
pObject.Save();
End Sub;
See also: