コード例 #1
0
        private async void IntializeChakraAndExecute(string function_name)
        {
            /*
             * =============================
             * = ADDONS EXECUTOR VARIABLES =
             * =============================
             */


            host.Chakra.ProjectObjectToGlobal(_SCEELibs, "sceelibs");


            /*
             * ===========================
             * = ADDONS EXECUTOR CONTENT =
             * ===========================
             */


            InfosModule ModuleAccess = ModulesAccessManager.GetModuleViaID(_id);
            StorageFile MainFile     = AsyncHelpers.RunSync(async() => await StorageFile.GetFileFromApplicationUriAsync(new Uri(ModulesAccessManager.GetModuleFolderPath(ModuleAccess.ID, ModuleAccess.ModuleSystem) + "main.js")));

            foreach (string Path in ModuleAccess.JSFilesPathList)
            {
                try
                {
                    StorageFile FileFromPath = AsyncHelpers.RunSync(async() => await StorageFile.GetFileFromApplicationUriAsync(new Uri(ModulesAccessManager.GetModuleFolderPath(ModuleAccess.ID, ModuleAccess.ModuleSystem) + Path)));
                    host.Chakra.RunScript(AsyncHelpers.RunSync(async() => await FileIO.ReadTextAsync(FileFromPath)));
                }
                catch
                {
                    Debug.WriteLine("Erreur ! :(");
                }
            }

            try
            {
                string code = AsyncHelpers.RunSync(async() => await FileIO.ReadTextAsync(MainFile));
                host.Chakra.RunScript(code);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            try
            {
                host.Chakra.CallFunction(function_name);
            }
            catch { }
        }