-
-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to handle anything dynamically #24
Comments
Exactly what kind of behavior are you looking for here? You can't implement a dynamic interface but if you implement IHandleMessages < object > and change the object to dynamic in the Handle-method you basicly have dynamic message handling. The dispatcher will dispatch any message to the handler (if you change the implementation of IActivateHandlers and IDetermineDestination aswell) since anything is object and the Handler having dynamic in the method-signatur will allow you to call anything (at compiletime) on that object. I modified the sample project to show off this already supported feature using ExpandoObject. Anonymous object weren't posible since the json serializer threw up when it tried to deserialize the transportmessage in the worker however with a working serializer it won't be a problem, the message gets serialized and is put in the server-queue, the server just can't desirialize the anonymous object. |
Hmm, maybe exposing an abstract class DynamicMessageHandler : IHandleMessage < object > which already have the Handle(object message) changed to Handle(dynamic message) would be an idea, this way whoever wanted to have dynamic message handling wouldn't have to know this small workaround - if you can call it that - they just need to inherit from DynamicMessageHandler. Obviously that could be a problem for anyone needing to inherit from another baseclass aswell but it would be a nice "api-workaround" for those who don't. |
Yeah, well - I'm actually unsure as to whether |
Even though this scenario may seem kind of whack, I think it is already supported. C# doesn't allow a class to implement Just remember that the message type must be public for this to work ;) as the runtime binder seems to respect access modifiers. |
by implementing
IHandleMessages<dynamic>
. That would be cool!(not sure how an
IHandleMessages<dynamic>
would actually behave at the moment... is it just a question of having theDispatcher
resolve those as well?The text was updated successfully, but these errors were encountered: