public override object GetProperty(string name, object[] args) { VerifyNotDisposed(); var result = engine.MarshalToHost(engine.ScriptInvoke(() => { try { return(target.InvokeMember(name, BindingFlags.GetProperty, null, target, engine.MarshalToScript(args), null, CultureInfo.InvariantCulture, null)); } catch (Exception) { if (target.GetMethod(name, BindingFlags.GetProperty) != null) { // Property retrieval failed, but a method with the given name exists; // create a tear-off method. This currently applies only to VBScript. return(new ScriptMethod(this, name)); } return(Nonexistent.Value); } }), false); var resultScriptItem = result as WindowsScriptItem; if ((resultScriptItem != null) && (resultScriptItem.engine == engine)) { resultScriptItem.holder = this; } return(result); }
public override object GetProperty(string name, params object[] args) { VerifyNotDisposed(); var result = engine.MarshalToHost(engine.ScriptInvoke(() => { try { var value = target.GetProperty(name, false, engine.MarshalToScript(args)); return((value is Nonexistent) ? Undefined.Value : value); } catch (Exception exception) { if (!name.IsDispIDName(out _) && (exception.HResult != HResult.DISP_E_UNKNOWNNAME)) { // Property retrieval failed, but a method with the given name exists; // create a tear-off method. This currently applies only to VBScript. return(new ScriptMethod(this, name)); } return(Undefined.Value); } }), false); if ((result is WindowsScriptItem resultScriptItem) && (resultScriptItem.engine == engine)) { resultScriptItem.holder = this; } return(result); }