Ejemplo n.º 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);
                    }
            }
Ejemplo n.º 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);
        }
Ejemplo n.º 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.");
            }
        }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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);
            }
Ejemplo n.º 7
0
 public void SetProperty(string propertyName, NetVariant value)
 {
     Interop.NetJsValue.SetProperty(Handle, propertyName, value?.Handle ?? IntPtr.Zero);
 }
Ejemplo n.º 8
0
 public void Add(NetVariant variant)
 {
     Interop.NetVariantList.Add(Handle, variant.Handle);
 }