Esempio n. 1
0
        public static void RunModule(this ChakraContext context, string script, string rootFolder = "", params string[] addtionalSearchPattern)
        {
            ModuleLocator locator = new ModuleLocator(rootFolder);

            locator.SearchPatterns.AddRange(addtionalSearchPattern);
            context.RunModule(script, locator.LoadModule);
        }
Esempio n. 2
0
        public static JSValue ProjectModuleClass(this ChakraContext context, string moduleName, string className, string rootFolder = "", params string[] addtionalSearchPattern)
        {
            ModuleLocator locator = new ModuleLocator(rootFolder);

            locator.SearchPatterns.AddRange(addtionalSearchPattern);
            string projectTo = "__ModuleInstance__" + Guid.NewGuid().ToString().Replace('-', '_');

            return(context.ProjectModuleClass(projectTo, moduleName, className, locator.LoadModule));
        }
Esempio n. 3
0
        public static void EnableRequire(ChakraContext context, string rootPath = null)
        {
            JSRequireLoader loader = new JSRequireLoader()
            {
                RootPath = rootPath
            };

            context.GlobalObject.Binding.SetFunction <string, string>("_loadLib", loader.LoadLib);
            context.RunScript(Properties.Resources.ResourceManager.GetString("JSRequire"));
        }
Esempio n. 4
0
 /// <summary>
 /// Create a new context for script execution
 /// </summary>
 /// <param name="enableDebug">Not used by now</param>
 /// <returns></returns>
 public ChakraContext CreateContext(bool enableDebug)
 {
     try
     {
         var c      = runtime.CreateContext();
         var result = new ChakraContext(c, this, SyncHandler);
         result.Init(enableDebug);
         return(result);
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }