Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void DoConsume(T batchMsg)
- {
- EnsureThat.IsNotNull(batchMsg);
- IEnumerable<IMessage> msgs = from e in batchMsg.Batch select (IMessage) JsonConvert.DeserializeObject(e.Data, _serializerSettings);
- foreach (IMessage msg in msgs)
- {
- Type eType = msg.GetType();
- IMessage c = msg;
- IEnumerable<Type> consumerTypes = from t in _consumers
- from i in t.GetInterfaces()
- where i.IsGenericType && i.GetGenericArguments()[0] == eType
- select t;
- foreach (Type consumerType in consumerTypes)
- {
- object consumer = _scope.Resolve(consumerType);
- MethodInfo minfo = consumerType.GetMethod("Consume", new[] {eType});
- minfo.Invoke(consumer, new[] {c});
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment