IRdsDictionaryInstance.CreateDimInstance

Syntax

CreateDimInstance: IDimInstance;

Description

The CreateDimInstance method returns dictionary data on the base of the current set of elements of the MDM dictionary.

Comments

This method returns values of system attributes, or all attributes of the MDM dictionary, depending on the value defined for the IRdsDictionaryInstance.FetchAll property.

NOTE. This method does not get values of imported attributes.

If you directly cast the IRdsDictionaryInstance interface to IDimInstance, cached data is returned. When you use the CreateDimInstance method, it returns data based on actual set of elements. Use CreateDimInstance to get current data.

Example

Executing the example requires a form with the Button1 button, the RdsDictionaryBox component named RdsDictionaryBox1, and the UiRdsDictionary component that is a data source for RdsDictionaryBox1. An MDM dictionary is loaded to RdsDictionaryBox1.

This example is a handler of the OnClick event for the Button1 button.

Add a link to the Dimensions system assembly.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    DictInst: IRdsDictionaryInstance;
    Inst: IDimInstance;
    Elems: IDimElements;
    ElemArr: IDimElementArray;
    Iter: IDimIterator;
    Ats: IDimAttributesInstance;
    Atr: IDimAttributeInstance;
    i: Integer;
    s: String;
Begin
    DictInst := RdsDictionaryBox1.Source.Instance;
    
// Load values of system and custom attributes to cache
    DictInst.FetchAll := True;
    
// Get dictionary data
    Inst := DictInst As IDimInstance;
    
// Get dictionary elements
    Elems := Inst.Elements;
    ElemArr := Inst.RootElements;
    Iter := ElemArr.Iterator;
    
// Get dictionary attributes
    Ats := Inst.Attributes;
    
// Output attribute values
    Debug.WriteLine("Values of attributes for root elements:");
    
While Iter.Next Do
        Debug.WriteLine(
"Element " + Iter.Position.ToString);
        Debug.Indent;
        
For i := 0 To Ats.Count - 1 Do
            s := 
"";
            Atr := Ats.Item(i);
            s := Atr.Attribute.Name + 
": ";
            s := s + Atr.Value(Iter.Element);
            Debug.WriteLine(s);
        
End For;
        Debug.Unindent;
        
If Iter.Position = 9 Then
            
Break;
        
End If;
    
End While;
End Sub Button1OnClick;

Example execution result: the console window displays attribute values for the first ten root elements of the MDM dictionary loaded to RdsDictionaryBox1.

See also:

IRdsDictionaryInstance