Closed ghost closed 8 years ago
Can you give me a snippet of code for the scenario that's now broken for you?
My code is too heavy and I'm not really allowed to share it.
But here is the scenario I brought to you on JabbR :
« I have a broker set up for several different services.
Then I loop over a List
« problem, they're then only known as "Notification" so
the GetRegistrations generic method finds no candidate service to send
queue them to
« for instance you can have a list of two notifs :
[BlackberryNotification, AndroidNotification], then you loop with
foreach(var notif in list)
« I can't call QueueNotification<typeof(notif)>(notif) at runtime
« but I CAN call QueueNotification(notif) with no generics, which will call GetRegistrations(typeof(notif))
« instead of GetRegistrations
So basicallythe generic methods prevent you from doing polymorphic calls. It used to work when they weren't generic (and they're not on my modified version of PushSharp, it's mostly a simple revert change.
I hope I'm clear enough, thank you once more for your time.
Greetings from France, hope everything's alright in Canada
:)
Le Jeudi 28 novembre 2013 21h19, Jon Dick notifications@github.com a écrit :
Can you give me a snippet of code for the scenario that's now broken for you? — Reply to this email directly or view it on GitHub.
The ServiceRegistration support on the last version of PushBroker makes the method GetRegistrations (and QueueNotification) generic. Because of that, polymorphic QueueNotification(notif) calls with notif being of superclass Notification type are no longer possible.
The solution to this is to remove all genericity and use a type like before, this way:
et caetera. All these methods would have a paramater Type type instead of a type parameter TPushNotification, or the latter adds a compiling-time constraint to the notification queueing.