예제 #1
0
            public object InvokeMethod(string methodName, params object[] parameters)
            {
                NetVariantList variantParameters = null;

                if (parameters != null && parameters.Length > 0)
                {
                    variantParameters = new NetVariantList();
                    foreach (var parameter in parameters)
                    {
                        using (var variantParameter = NetVariant.From(parameter))
                        {
                            variantParameters.Add(variantParameter);
                        }
                    }
                }
                using (variantParameters)
                    using (var result = _qObject.InvokeMethod(methodName, variantParameters))
                    {
                        if (result == null)
                        {
                            return(null);
                        }
                        object unpacked = null;
                        Helpers.Unpackvalue(ref unpacked, result);
                        result.Dispose();
                        return(unpacked);
                    }
            }
예제 #2
0
        public object Call(params object[] parameters)
        {
            NetVariantList variants = null;

            if (parameters != null && parameters.Length > 0)
            {
                variants = new NetVariantList();
                foreach (var parameter in parameters)
                {
                    using (var variant = new NetVariant())
                    {
                        Helpers.PackValue(parameter, variant);
                        variants.Add(variant);
                    }
                }
            }

            var result = Call(variants);

            variants?.Dispose();

            if (result == null)
            {
                return(null);
            }

            object returnValue = null;

            Helpers.Unpackvalue(ref returnValue, result);
            result.Dispose();

            return(returnValue);
        }
예제 #3
0
        public void SetProperty(string propertyName, NetVariant value)
        {
            byte wasSuccessful = 0;

            Interop.NetQObject.SetProperty(Handle, propertyName, value?.Handle ?? IntPtr.Zero, ref wasSuccessful);
            if (wasSuccessful == 0)
            {
                throw new Exception("Setting property failed.");
            }
        }
예제 #4
0
 public void SetProperty(string propertyName, object value)
 {
     if (value == null)
     {
         _jsValue.SetProperty(propertyName, null);
     }
     else
     {
         using (var variant = new NetVariant())
         {
             Helpers.Pack(value, variant, value.GetType());
             _jsValue.SetProperty(propertyName, variant);
         }
     }
 }
예제 #5
0
 public void SetProperty(string propertyName, object value)
 {
     if (value == null)
     {
         _qObject.SetProperty(propertyName, null);
     }
     else
     {
         using (var variant = new NetVariant())
         {
             Helpers.PackValue(value, variant);
             _qObject.SetProperty(propertyName, variant);
         }
     }
 }
예제 #6
0
            public override bool TrySetMember(SetMemberBinder binder, object value)
            {
                if (value == null)
                {
                    _jsValue.SetProperty(binder.Name, null);
                }
                else
                {
                    using (var variant = new NetVariant())
                    {
                        Helpers.PackValue(value, variant);
                        _jsValue.SetProperty(binder.Name, variant);
                    }
                }

                return(true);
            }
예제 #7
0
 public void SetProperty(string propertyName, NetVariant value)
 {
     Interop.NetJsValue.SetProperty(Handle, propertyName, value?.Handle ?? IntPtr.Zero);
 }
예제 #8
0
 public void Add(NetVariant variant)
 {
     Interop.NetVariantList.Add(Handle, variant.Handle);
 }