Exemple #1
0
        public void InvokeMethod(IntPtr m, IntPtr t, IntPtr p, IntPtr r)
        {
            using (var method = new NetMethodInfo(m))
                using (var target = new NetReference(t))
                    using (var parameters = new NetVariantList(p))
                        using (var result = r != IntPtr.Zero ? new NetVariant(r) : null)
                        {
                            CodeGen.CodeGen.InvokeMethodDelegate del;
                            if (!_cachedInvokeMethods.TryGetValue(method.Id, out del))
                            {
                                del = CodeGen.CodeGen.BuildInvokeMethodDelegate(method);
                                _cachedInvokeMethods[method.Id] = del;
                            }

                            Task resultTask = null;
                            del(target, parameters, result, ref resultTask);

                            if (QmlNetConfig.ListenForExceptionsWhenInvokingTasks)
                            {
                                resultTask?.ContinueWith(
                                    task =>
                                {
                                    QmlNetConfig.RaiseUnhandledTaskException(task.Exception);
                                },
                                    TaskContinuationOptions.OnlyOnFaulted);
                            }
                        }
        }
Exemple #2
0
        public bool ActivateSignal(string signalName, params object[] parameters)
        {
            QmlNetConfig.EnsureUIThread();

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

                    return(Interop.NetReference.ActivateSignal(Handle, signalName, list.Handle) == 1);
                }
            }
            else
            {
                return(Interop.NetReference.ActivateSignal(Handle, signalName, IntPtr.Zero) == 1);
            }
        }
Exemple #3
0
        public void CallComponentCompleted(IntPtr t)
        {
            using (var target = new NetReference(t))
            {
                var instance           = target.Instance;
                var componentCompelted = instance as IQmlComponentCompleted;
                if (componentCompelted == null)
                {
                    throw new Exception($"Type {instance.GetType().FullName} doesn't implement IQmlComponentCompleted");
                }

                var result = componentCompelted.ComponentCompleted();
                if (QmlNetConfig.ListenForExceptionsWhenInvokingTasks)
                {
                    result?.ContinueWith(
                        task =>
                    {
                        QmlNetConfig.RaiseUnhandledTaskException(task.Exception);
                    },
                        TaskContinuationOptions.OnlyOnFaulted);
                }
            }
        }