Hooks by which you can modify and/or override certain features of the web browsing
+
+ A fix to allow params to be used by the .NET methods called by the javascript
+
+
+
+
+
+
diff --git a/CefSharp.Example/ScriptedMethodsBoundObject.cs b/CefSharp.Example/ScriptedMethodsBoundObject.cs
index 406e0131dc..d1bff280d5 100644
--- a/CefSharp.Example/ScriptedMethodsBoundObject.cs
+++ b/CefSharp.Example/ScriptedMethodsBoundObject.cs
@@ -2,6 +2,7 @@
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
+using System.Linq;
namespace CefSharp.Example
{
@@ -35,5 +36,26 @@ public void RaiseEvent(string eventName, object eventData = null)
EventArrived(eventName, eventData);
}
}
+
+ ///
+ /// Demonstrates the use of params as an argument in a bound object
+ ///
+ /// Dummy Argument
+ /// Params Argument
+ public void MethodWithParams(string name, params object[] args)
+ {
+ var test = args.ElementAtOrDefault(0);
+ var test2 = args.ElementAtOrDefault(1);
+ }
+
+ public void MethodWithoutParams(string name, string arg2)
+ {
+ var test = arg2;
+ }
+
+ public void methodWithoutAnything()
+ {
+ var test = "";
+ }
}
}
diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj
index 9a156e623d..66542492d9 100644
--- a/CefSharp/CefSharp.csproj
+++ b/CefSharp/CefSharp.csproj
@@ -89,6 +89,7 @@
+
diff --git a/CefSharp/Internals/JavascriptMethod.cs b/CefSharp/Internals/JavascriptMethod.cs
index d6ee5065b4..8b9738f177 100644
--- a/CefSharp/Internals/JavascriptMethod.cs
+++ b/CefSharp/Internals/JavascriptMethod.cs
@@ -3,6 +3,7 @@
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
+using System.Collections.Generic;
using System.Runtime.Serialization;
namespace CefSharp.Internals
@@ -33,6 +34,9 @@ public class JavascriptMethod
[DataMember]
public string JavascriptName { get; set; }
+ [DataMember]
+ public List MethodParameters { get; set; }
+
///
/// Number of Params this function exepects
///
diff --git a/CefSharp/Internals/JavascriptObjectRepository.cs b/CefSharp/Internals/JavascriptObjectRepository.cs
index b02bc5743e..17527ffba9 100644
--- a/CefSharp/Internals/JavascriptObjectRepository.cs
+++ b/CefSharp/Internals/JavascriptObjectRepository.cs
@@ -104,15 +104,33 @@ public bool TryCallMethod(long objectId, string name, object[] parameters, out o
try
{
- // Do we have enough arguments? Add Type.Missing for any that we don't have incase of optional params
+ //Fix for C# paramArray and refactor on arguments mismatch 03/22/2016
var missingParams = method.ParameterCount - parameters.Length;
- if (missingParams > 0)
+ if (missingParams > 0 || method.MethodParameters.Any(t => t.IsParamArray))
{
- var paramList = new List