Esempio n. 1
0
        public static int Run(string[] args, Func <string[], QGuiApplication, QQmlApplicationEngine, NetRunCallbackDelegate, int> action)
        {
            if (args.Length < 4)
            {
                throw new Exception("Args is invalid, must contain three entries which are pointers to native types.");
            }

            var appPtr            = new IntPtr((long)ulong.Parse(args[0]));
            var enginePtr         = new IntPtr((long)ulong.Parse(args[1]));
            var callbackPtr       = new IntPtr((long)ulong.Parse(args[2]));
            var exportedSymbolPtr = new IntPtr((long)ulong.Parse(args[3]));

            GetExportedSymbol = Marshal.GetDelegateForFunctionPointer <GetExportedSymbolDelegate>(exportedSymbolPtr);

            using (var app = new QGuiApplication(appPtr))
            {
                using (var engine = new QQmlApplicationEngine(enginePtr))
                {
                    var runCallback = new NetRunCallbackDelegate(() =>
                    {
                        var callback = Marshal.GetDelegateForFunctionPointer <NativeRunCallbackDelegate>(callbackPtr);
                        // ReSharper disable AccessToDisposedClosure
                        return(callback.Invoke(app.InternalPointer, engine.InternalPointer));
                        // ReSharper restore AccessToDisposedClosure
                    });
                    return(action(args.Skip(2).ToArray(), app, engine, runCallback));
                }
            }
        }
Esempio n. 2
0
File: Qml.cs Progetto: xlmnxp/qmlnet
 public static int RegisterType(Type type, string qmlName, string uri, int versionMajor = 1, int versionMinor = 0)
 {
     using (var typeInfo = NetTypeManager.GetTypeInfo(type))
     {
         return(QQmlApplicationEngine.RegisterType(typeInfo, uri, qmlName, versionMajor, versionMinor));
     }
 }
Esempio n. 3
0
 public static int RegisterType <T>(string uri, int versionMajor = 1, int versionMinor = 0)
 {
     return(QQmlApplicationEngine.RegisterType(NetTypeManager.GetTypeInfo <T>(), uri, typeof(T).Name, versionMajor, versionMinor));
 }