Somewhere inside my function I need to do something like that:
smsg["isin"].set(ii.ISIN);
smsg["client_code"].set(Constants.CLIENT_CODE);
smsg["type"].set(1);
smsg["dir"].set(order.Operation == Side.Buy ? 1 : 2);
smsg["amount"].set(order.Lots);
smsg["price"].set(textPrice);
smsg["ext_id"].set(0);
set method has a lot of overloads it can accept int, string, boolean, DateTime etc. totally about 15 methods.
After refactoring I decided function to use just list of parameters ignoring other variables order ii etc. The problem is that I don’t know how can I transfer this parameters via function arguments
public uint ExecuteTransaction(Dictionary<string, object> parameters)
{
....
foreach (var parameter in parameters)
{
smsg[parameter.Key].set(parameter.Value); // compile time error!
}
Compiler doesn’t know which overload to use and so I have such error:
The best overloaded method match has some invalid arguments
My Dictionary contains appropiate value for each parameter. So boolean parameters contain boolean value etc. That’s why I declared Dictionary to contain general type object.
Thanks for your help!
You should implement the set(object value) method which will determine parameter type and call typed set(T value). This is only way to use set in this maner.
Upd: if you haven’t access to set as it a library you can write extension method