perlun/CefSharp — pull request #7 by EMonk72 (2013-07-02 03:46:22+00:00)
Title: Binding Updates: More flexible argument matching

Reimplemented BindingHandler::FindBestMethod to support a range of options including C#-style param arrays and optional parameters with default values.
Changed method name scanning to use HashSet instead of Dictionary to simplify duplicate name handling.

Now supports methods such as (C#):

```csharp
public class testcls
{
public void method1(params object[] parms)
{ }

public void method2(int a, int b)
{ }

public void method2(int a, string b = "abcd")
{ }
}
```

JavaScript examples:

```js
// calls to method1 with variable number of parameters
test.method1(); // no parameters passed, calls method1 with empty array
test.method1(1, 2);
test.method1(1, 2, 'xyz');

// calls to method2 with variable parameters
test.method2(1, 2); // first variant of method2
test.method2(1, 'xyz'); // second variant of method2
test.method2(1); // second variant of method2 with default parameter
test.method2(1, 2, 3); // fails with argument exception
```

Runtime type inspection does not distinguish between parameters with the `params` keyword and without - this is C# syntactic sugar similar to `...` in C++. I am simply checking for an array of objects as the last item in the parameter list and pouring any remaining arguments into it.

Suggestions for improvement welcome.