public static JavaScriptHostingConfig AddModuleFolder(this JavaScriptHostingConfig config, string scriptRootFolder)
        {
            ModuleLocator locator = new ModuleLocator(scriptRootFolder);

            config.ModuleFileLoaders.Add(locator.LoadModule);
            return(config);
        }
Exemplo n.º 2
0
        public ChakraContext CreateContext(JavaScriptHostingConfig config)
        {
            var result = createContext(createRuntime());

            initContext(result, config);
            return(result);
        }
Exemplo n.º 3
0
        public TResult GetModuleClass <TResult>(string moduleName, string className, JavaScriptHostingConfig config) where TResult : IJSValueWrapper, new()
        {
            var     jsvalue = GetModuleClass(moduleName, className, config);
            TResult result  = new TResult();

            result.SetValue(jsvalue);
            return(result);
        }
Exemplo n.º 4
0
        public ChakraContext CreateContext(JavaScriptHostingConfig config)
        {
            var result = createContext(createRuntime());

            initContext(result, config);
            config.DebugAdapter?.Init(result.ServiceNode.GetService <IRuntimeDebuggingService>());
            return(result);
        }
 public static JavaScriptHostingConfig AddModuleFolder(this JavaScriptHostingConfig config, StorageFolder folder)
 {
     config.ModuleFileLoaders.Add((name) =>
     {
         var t = loadModuleFromFolderAsync(folder, name);
         t.Wait();
         return(t.Result);
     });
     return(config);
 }
 public static JavaScriptHostingConfig AddPlugin(this JavaScriptHostingConfig config, IPluginInstaller plugin)
 {
     return(config.AddPlugin((name) =>
     {
         if (plugin.Name == name)
         {
             return plugin;
         }
         return null;
     }));
 }
 public static JavaScriptHostingConfig AddModuleScript <T>(this JavaScriptHostingConfig config, string name, string script)
 {
     config.ModuleFileLoaders.Add((n) =>
     {
         if (n == name)
         {
             return(script);;
         }
         return(null);
     });
     return(config);
 }
 public static JavaScriptHostingConfig AddModuleScript <T>(this JavaScriptHostingConfig config, string name, string script, string url = null)
 {
     config.ModuleFileLoaders.Add((n) =>
     {
         if (n == name)
         {
             return(new ModuleInfo {
                 SourceCode = script, Url = url
             });
         }
         return(null);
     });
     return(config);
 }
Exemplo n.º 9
0
 public Task <JSValue> GetModuleClassAsync(string proxyTemplate, string moduleName, string className, JavaScriptHostingConfig config)
 {
     return(Task.Factory.StartNew(() => { return GetModuleClass(proxyTemplate, moduleName, className, config); }));
 }
Exemplo n.º 10
0
        public JSValue GetModuleClass(string proxyTemplate, string moduleName, string className, JavaScriptHostingConfig config)
        {
            var    context   = CreateContext(config);
            string projectTo = "X" + Guid.NewGuid().ToString().Replace('-', '_');

            return(context.ProjectModuleClass(proxyTemplate, moduleName, className, config.LoadModule));
        }
Exemplo n.º 11
0
        public JSValue GetModuleClass(string moduleName, string className, JavaScriptHostingConfig config)
        {
            var context = CreateContext(config);

            return(context.ProjectModuleClass(moduleName, className, config.LoadModule));
        }
Exemplo n.º 12
0
 public virtual void RunScript(string script, JavaScriptHostingConfig config)
 {
     CreateContext(config).RunScript(script);
 }
Exemplo n.º 13
0
 protected virtual void initContext(ChakraContext context, JavaScriptHostingConfig config)
 {
     PluginManager pluginManager = new PluginManager(context, config.LoadPlugin);
 }
Exemplo n.º 14
0
        public static JavaScriptHostingConfig EnableHosting(this JavaScriptHostingConfig config, ResolveConfigFunction resolve)
        {
            ModuleHosting hosting = new ModuleHosting(resolve);

            return(config.AddPlugin(hosting));
        }
Exemplo n.º 15
0
 public Task <TResult> GetModuleClassAsync <TResult>(string proxyTemplate, string moduleName, string className, JavaScriptHostingConfig config) where TResult : IJSValueWrapper, new()
 {
     return(Task.Factory.StartNew(() => { return GetModuleClass <TResult>(proxyTemplate, moduleName, className, config); }));
 }
        public static JavaScriptHostingConfig AddModuleFolderFromCurrentAssembly(this JavaScriptHostingConfig config)
        {
            string folder = new System.IO.FileInfo(System.Reflection.Assembly.GetCallingAssembly().Location).DirectoryName;

            return(config.AddModuleFolder(folder));
        }
 public static JavaScriptHostingConfig Clone(this JavaScriptHostingConfig config)
 {
     return(new JavaScriptHostingConfig(config));
 }
 public static JavaScriptHostingConfig AddPlugin <T>(this JavaScriptHostingConfig config) where T : IPluginInstaller, new()
 {
     return(config.AddPlugin(new T()));
 }
 public static JavaScriptHostingConfig AddPlugin(this JavaScriptHostingConfig config, LoadPluginInstallerFunction loadCallback)
 {
     config.PluginLoaders.Add(loadCallback);
     return(config);
 }
Exemplo n.º 20
0
 public JavaScriptHostingConfig(JavaScriptHostingConfig source) : this()
 {
     PluginLoaders.AddRange(source.PluginLoaders);
     ModuleFileLoaders.AddRange(source.ModuleFileLoaders);
 }
Exemplo n.º 21
0
        public static JavaScriptHostingConfig AddPluginFolder(this JavaScriptHostingConfig config, string folderPath)
        {
            var loader = new DirectoryLoader(folderPath);

            return(config.AddPluginLoader(loader.Load));
        }