I am calling rest API from a loop and my object name is being decided at runtime. I am able to use reflection here for one object but how to get list of object?
foreach (CloudDBTableList table in cloudDBTableList)
{
string uri = string.Format(table.URI, "1-Jan-2011");
string result = _dataPullSvcAgent.GetData (baseURI + uri);
string tableClassType = table.TableName + ", " + namespacePrefix;//namespacePrefix is same as assembly name.
Type t = Type.GetType(tableClassType);
JavaScriptSerializer jsonDeserializer = new JavaScriptSerializer();
//t is only type of object whereas below method returns List<t> how to put it?
var objectList = jsonDeserializer.Deserialize(result, t);
}
return true;
}
Stackoverflow Rocks. Found answer from this question(though below question was bit dfferent from mine):-
How to dynamically create generic C# object using reflection?
I modified my code like this:-