private static object ConvertObjectToJavaScriptObject(object arg) { IWrapsElement wrapsElement = arg as IWrapsElement; RemoteWebElement remoteWebElement = arg as RemoteWebElement; IEnumerable enumerable = arg as IEnumerable; IDictionary dictionary = arg as IDictionary; if (remoteWebElement == null && wrapsElement != null) { remoteWebElement = (wrapsElement.WrappedElement as RemoteWebElement); } object result; if (arg is string || arg is float || arg is double || arg is int || arg is long || arg is bool || arg == null) { result = arg; } else if (remoteWebElement != null) { result = new Dictionary <string, object> { { "ELEMENT", remoteWebElement.InternalElementId }, { "element-6066-11e4-a52e-4f735466cecf", remoteWebElement.InternalElementId } }; } else if (dictionary != null) { Dictionary <string, object> dictionary2 = new Dictionary <string, object>(); foreach (object current in dictionary.Keys) { dictionary2.Add(current.ToString(), RemoteWebDriver.ConvertObjectToJavaScriptObject(dictionary[current])); } result = dictionary2; } else { if (enumerable == null) { throw new ArgumentException("Argument is of an illegal type" + arg.ToString(), "arg"); } List <object> list = new List <object>(); foreach (object current2 in enumerable) { list.Add(RemoteWebDriver.ConvertObjectToJavaScriptObject(current2)); } result = list.ToArray(); } return(result); }
private static object[] ConvertArgumentsToJavaScriptObjects(object[] args) { if (args == null) { return(new object[1]); } for (int i = 0; i < args.Length; i++) { args[i] = RemoteWebDriver.ConvertObjectToJavaScriptObject(args[i]); } return(args); }