Exemplo n.º 1
0
        //
        // GET: /Home/
        public ActionResult Index(PreviewModel data)
        {
            var model = new Models.PreviewModel() { FormWidth = 600 };

            if (data.FormWidth > 0)
                model.FormWidth = data.FormWidth;

            String src = null;

            if (!String.IsNullOrEmpty(data.FilePath))
                src = System.IO.File.ReadAllText(data.FilePath);
            else if (Request.Files.Count == 1)
            {
                var sr = new StreamReader(Request.Files[0].InputStream);
                src = sr.ReadToEnd();
                data.FilePath = Request.Files[0].FileName;
                model.IsUpload = true;
            }

            if (src != null)
            {
                var dc = new DynamicCompiler
                {
                    BinPath = HttpRuntime.BinDirectory
                };
                model.FilePath = data.FilePath;
                var code = dc.Compile(src);
                model.InlineJsCode = new HtmlString(code);
            }

            return View(model);
        }
Exemplo n.º 2
0
 public void Test()
 {
     var code = File.ReadAllText("TestCode.cs");
     var dynamicCompiler = new DynamicCompiler
     {
         BinPath = Environment.CurrentDirectory
     };
     var res = dynamicCompiler.Compile(code);
 }