Пример #1
0
        public string Compile(string source, params object[] args)
        {
            if (source == null)
            {
                throw new ArgumentException("source cannot be null.", "source");
            }

            object[] compileArgs = null;
            if (args != null && args.Length > 0)
            {
                compileArgs    = new object[args.Length + 1];
                compileArgs[0] = source;
                args.CopyTo(compileArgs, 1);
            }
            else
            {
                compileArgs = new object[] { source };
            }

            lock (syncLock)
            {
                Initialize();
                return(js.ExecuteFunction <string>(CompilationFunctionName, compileArgs));
            }
        }
Пример #2
0
 /// <summary>
 /// Compiles the TypeScript
 /// </summary>
 /// <param name="engine"></param>
 /// <param name="typeScript"></param>
 /// <returns></returns>
 internal string CompileTypeScript(IJavaScriptRuntime engine, string typeScript)
 {
     using (engine)
     {
         var result = engine.ExecuteFunction <string>("compileTsSource", typeScript, JsLibs.lib_d);
         if (TypeScriptCompilationErrorParser.HasErrors(result))
         {
             throw new TypeScriptCompilationException(TypeScriptCompilationErrorParser.Parse(result).ToArray());
         }
         return(result);
     }
 }
Пример #3
0
        public string Compile(string source)
        {
            if (source == null)
            {
                throw new ArgumentException("source cannot be null.", "source");
            }

            lock (_lock) {
                Initialize();
                return(_js.ExecuteFunction <string>(CompilationFunctionName, source));
            }
        }
Пример #4
0
 /// <summary>
 /// Compiles the TypeScript
 /// </summary>
 /// <param name="engine"></param>
 /// <param name="typeScript"></param>
 /// <returns></returns>
 internal string CompileTypeScript(IJavaScriptRuntime engine, string typeScript)
 {          
     using (engine)
     {
         var result = engine.ExecuteFunction<string>("compileTsSource", typeScript, JsLibs.lib_d);
         if (TypeScriptCompilationErrorParser.HasErrors(result))
         {
             throw new TypeScriptCompilationException(TypeScriptCompilationErrorParser.Parse(result).ToArray());
         }
         return result;    
     }
 }