Below is the example of using the GetDimElements operation to get information about specific elements that satisfy the specified filtering conditions. The request contains moniker of opened dictionary instance and getting parameters, in which the elements filter is specified. The filter uses text of objects' names, it is case-insensitive and searches for text in all parts of names. The basic information is loaded for the selected elements: key, name, element level and indication of child elements. Information is available in the response to the request.
In the C# example the text to be searched for in the names is sent as an input parameter.
{
"GetDimElements" :
{
"tDim" :
{
"id" : "S1!M!S!S1"
},
"tArg" :
{
"filter" :
{
"text" :
{
"attributes" : "NAME",
"text" : "second",
"wholeWordsOnly" : "false",
"caseSensitive" : "false"
},
"includeParents" : "true",
"includeParentsWithSiblings" : "true"
},
"pattern" :
{
"getLevel" : "true",
"getImageIndex" : "true"
}
}
}
}
{
"GetDimElementsResult" :
{
"els" :
{
"e" :
[
{
"@x" : "1",
"@l" : "0",
"n" : "First element",
"k" : "1",
"h" : "1",
"o" : "0"
},
{
"@l" : "1",
"n" : "Second element",
"k" : "2",
"h" : "0",
"o" : "1"
},
{
"@x" : "1",
"@l" : "0",
"n" : "Fourth element",
"k" : "4",
"h" : "0",
"o" : "0"
},
{
"@x" : "1",
"@l" : "0",
"n" : "Fifth element",
"k" : "5",
"h" : "0",
"o" : "0"
}
]
},
"id" :
{
"id" : "S1!M!S!S1"
}
}
}
public static GetDimElementsResult GetFilteredElements(DmId moniker, string text)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var tElements = new GetDimElements()
{
tArg = new GetDimElementsArg()
{
pattern = new ElsPattern()
{
getLevel = true
},
//Element filtering parameters
filter = new ElsFilter()
{
text = new TextFilter()
{
attributes = "NAME",
text = text,
caseSensitive = false,
wholeWordsOnly = false
},
includeParents = true,
includeParentsWithSiblings = true
}
},
tDim = moniker
};
//Get information about dictionary elements
var result = somClient.GetDimElements(tElements);
return result;
}
See also: