I have a queue containing a bunch of class objects. If possible, I'd like to get them all and instantiate them as new objects dynamically.
Of course, such a description is not possible, but as an image, it is possible to collectively execute it like this.
// queueModel:the queue that's holding original class objects.
// also classModel has property "OriginalClassName" and it's including class name as string
// also corresponding classes are ready for new objects.
string className;
object obj = null;
do
{
var jObject = JObject.Parse(queueModel.Peek());
className = jObject["OriginalClassName"].ToString();
**className** obj = JsonConvert.DeserializeObject<**className**>(queueModel.Dequeue());
//If you specify it manually, it will look like this
// SomeClass obj = JsonConvert.DeserializeObject<SomeClass>(queueModel.Dequeue());
} while (queueModel.Count != 0);