예제 #1
0
 public void ProcessRequest(HttpContext context)
 {
     var localPath = context.Request.Url.LocalPath;
     if (string.IsNullOrEmpty(localPath)) return;
     var reader = new VirtualPathFileReader();
     var fileContents = reader.ReadFile(localPath);
     var writer = new TypeScriptWriter();
     var engine = writer.GetEngine();
     var output = writer.CompileTypeScript(engine, fileContents);
     context.Response.ContentType = "text/javascript";
     context.Response.Write(output);
 }
예제 #2
0
        public void Can_Get_Successfull_Result()
        {
            var compiler = new TypeScriptWriter();
            var engine = compiler.GetEngine();

            var test = @"function greeter(person: string) {
                            return ""Hello, "" + person;
                        }
                        var user = ""Jane User"";
                        document.body.innerHTML = greeter(user);";

            var result = compiler.CompileTypeScript(engine, test);
            Assert.IsFalse(TypeScriptCompilationErrorParser.HasErrors(result));            
        }
예제 #3
0
        public void ProcessRequest(HttpContext context)
        {
            var localPath = context.Request.Url.LocalPath;

            if (string.IsNullOrEmpty(localPath))
            {
                return;
            }
            var reader       = new VirtualPathFileReader();
            var fileContents = reader.ReadFile(localPath);
            var writer       = new TypeScriptWriter();
            var engine       = writer.GetEngine();
            var output       = writer.CompileTypeScript(engine, fileContents);

            context.Response.ContentType = "text/javascript";
            context.Response.Write(output);
        }
예제 #4
0
 public void Can_Create_Engine()
 {
     var compiler = new TypeScriptWriter();
     var engine = compiler.GetEngine();
     Assert.NotNull(engine);
 }
예제 #5
0
        public void Can_Get_Exception_Result()
        {
            var compiler = new TypeScriptWriter();
            var engine = compiler.GetEngine();

            var test = @"functio greeter(person: stringz) {
                                        return ""Hello, "" +=-+ person;
                                    
                                    var user = ""Jane User"";
                                    document.body.innerHTML = greeter(user);";


            Assert.Throws<TypeScriptCompilationException>(() => compiler.CompileTypeScript(engine, test));            
        }