Ejemplo n.º 1
0
        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);
        }