I would like to have a function that takes a dictionary of string, array of variant. So it can be called with:
searchDictionary := TDictionary<string, array of variant>;
searchDictionary.Add('KEY_NAME', ['X01%', '%D01']);
aValue := TDtoClass.Search(searchDictionary)
I am currently achieving this by
searchDictionary := TDictionary<string, TList<variant>>.Create;
searchDictionary.Add('BIN_NAME', TSearch.Values(['X01%', '%D01']));
where Tsearch is a class that exposes:
class function TSearch.Values(const arguments: array of variant): TList<variant>;
var
list : TList<variant>;
item: variant;
begin
list := TList<variant>.Create;
for item in arguments do
begin
list.Add(item);
end;
Result := list;
end;
What I would like to do is:
searchDictionary.Add('BIN_NAME', ['X01%', '%D01']);
instead of:
searchDictionary.Add('BIN_NAME', TSearch.Values(['X01%', '%D01']));
Any help will be greatly appreciated.
While there is no problem in declaring the dictionary, adding values might get somewhat tricky. You can use a special construct to get the required variant array:
var
searchDictionary: TDictionary<string, TArray<variant>>;
begin
searchDictionary.Add('BIN_NAME', TArray<variant>.Create('X01%', '%D01'));
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With