예제 #1
0
        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);
        }
예제 #2
0
 public override string[] GetPropertyNames()
 {
     VerifyNotDisposed();
     return(engine.ScriptInvoke(() => target.GetPropertyNames().ExcludeIndices().ToArray()));
 }
예제 #3
0
 public override string[] GetPropertyNames()
 {
     VerifyNotDisposed();
     return(engine.ScriptInvoke(() => target.GetProperties(BindingFlags.Default).Select(property => property.Name).ExcludeIndices().ToArray()));
 }