c# - Send Anonymous Object to Service Bus Queue in Azure -
i have method in c# takes set of properties wrapped in class , push azure service bus queue. there many types need pushed wrote method takes anonymous object , use brokeredmessaging class send service bus queue.
something along line:
//i intially used string type know type of class passed //and using switch statement, handle each case accordingly. //but becomes long list of switch statements , don't want that. public static bool queueup(object obj, string type) { var msg = new brokeredmessage(obj); _sendobjclient.send(msg); }
this code isn't working. i'd save many places method called passing in explicitly typed object; should send object , want portion of code hard work , send serialized queue.
just got introduced system.reflection
namespace i'm yet grab how achieve goal. appreciated.
you have mark class , properties of object serializable - how use service bus queues:
messages sent (and received from) service bus queues instances of brokeredmessage class. brokeredmessage objects have set of standard properties (such label , timetolive), dictionary used hold custom application specific properties, , body of arbitrary application data. application can set body of message passing serializable object constructor of brokeredmessage, , appropriate datacontractserializer used serialize object. alternatively, system.io.stream can provided.
then review serializableattribute class learn how mark class serializable.
Comments
Post a Comment