资 源 简 介
Description
Multimethods are dynamically dispatched methods that use all of their arguments to dispatch to the best overload for the arguments they are called with. This contrasts with the more usual virtual methods where just the target of a method call is used to dispatch to an override. multimethod-sharp contains a Python script which will generate a C# multimethod for a specific signature and attach overloads to it using any methods which are decorated with an attribute nested in the multimethod class.
Multimethods are useful whenever you want to extend a class hierarchy with a virtual method without disturbing the class itself or if you want to dispatch on two or more arguments. Examples of the later include collisions, drag and drop, writing objects to different formats, etc.
However, unlike ordinary virtual methods, multimethod calls may fail at runtime. Typically this is because an overload cannot be found which is usable with the actual arguments