perlun/CefSharp — pull request #8 by EMonk72 (2013-07-02 06:25:39+00:00)
Title: Binding Updates: More flexible argument matching (retry)

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.

**Update**
Original pull request omitted a code change and wouldn't compile. Re-pulled to fix.