I have a queue in Azure storage and I want to be able to add different message types to the queue and parse them as their specific types.
For example.
public class Customer
{
public Customer()
{
}
public string Name { get; set;}
public string Email { get; set;}
public string Address { get; set;}
}
public class Employee
{
public Employee()
{
}
public string Id { get; set;}
public string Name { get; set;}
public string Email { get; set;}
}
I can serialize them to JSON and add them to the queue, but how can I deserialize them to their specific types without knowing the type of the message?
How can I know that the next message is Customer or Employee? Can I add some kind of property to the message saying: "This is Customer" or "This is Employee" ...
Because I have a worker role that will look for messages in the queue and do specific action based on the type
get message from queue
If message = customer
do this
else if message = employee
do that
else
do nothing