How does SignalR allow the developer to call a function name that has not been defined in c#. An example would be:
Clients.All.sayHello("Greetings!");
The sayHello(string msg) has not been defined. The intellisense does not pick it up as expected but I'm curious as to how they have implemented it in the library to allow it.
The basis behind all of this is Dynamic Objects. These allow you to provide new type members at runtime rather than compile time:
Dynamic objects expose members such as properties and methods at run time, instead of in at compile time. This enables you to create objects to work with structures that do not match a static type or format.
(Or, as here, where the javascript definitions aren't available until runtime)
To create your own class that has such behaviour, you can extend DynamicObject
.
You could have discovered this as well by looking at the source:
public class ClientProxy : DynamicObject, IClientProxy
{
...