-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to invoke a method that implicit cast string, such as XElment.Elements(XName name) #115
Comments
Hi @dwanboweb, Currently ClearScript doesn't support implicit conversion operators for method arguments. Specifically, the call binds to the correct method, but ClearScript's invocation code can't perform the required conversion. We'll add that capability in the next release. What you're doing is exactly the workaround we'd recommend. You could make the conversion syntax slightly simpler by providing a wrapper function or extending the String prototype, but that's really a matter of preference; for now, unfortunately, you must do the conversion explicitly. Thanks for reporting this! |
…y, GitHub Issue #114); added initial support for CommonJS modules (V8 and JScript); added ScriptEngine.ExecuteDocument and ScriptEngine.EvaluateDocument; added V8ScriptEngine.CompileDocument and V8Runtime.CompileDocument; added support for machine-level deployment (GitHub Issue #117); added Extensions and JavaScriptExtensions to facilitate specific scenarios; added implicit conversion of host method arguments via user-defined operators (GitHub Issue #115); patched a V8 issue that causes occasional script execution failure in 32-bit processes (GitHub Issue #111); fixed accessibility of public methods overriden by internal classes (GitHub Issue #112); updated deployment and API documentation. Tested with V8 7.6.303.28.
ClearScript 5.6 adds support for implicit conversion operators for host method arguments. |
wow ,I just need this! |
Firstly,I try to use Linq xml in my Script,such as:
var XDocument=clr.System.Xml.Linq.XDocument var doc = XDocument.Load(xmlPath); var root = doc.Root; var patients = root.Elements('patient');
And it makes error.It seems that 'string' cannot be implicit to the 'XName'.
So I have to write as
var patients = root.Elements(Lib.GetXName('patient'));
public XName GetXName(string name) { return (XName)name; }
Is there any more elegant way?As 'XName' is used frequently.
Thank you very much
The text was updated successfully, but these errors were encountered: