public ScriptOutput Run(ScriptInput input) { var co = new ScriptOutput(); co.Code = input.Code; co.Output = CompileHelper.CompileAndRun(string.Format(input.Language == Language.CSharp?CodeSamples.ScriptWrapperCSharp:CodeSamples.ScriptWrapperVBNet, input.Code), input.Language); return(co); }
public ActionResult Run(CodeViewModel vm) { _logRepository.Insert(new Log { InputCode = vm.InputCode, IpAddress = Request.UserHostAddress }); return(new ContentResult { Content = CompileHelper.CompileAndRun(vm.InputCode) }); }
public ConsoleOutput Run(ConsoleInput input) { _logRepository.Insert(new Log { InputCode = input.Code, IpAddress = GetClientIp(Request) }); //TODO: use Roslyn to compile and run var co = new Models.ConsoleOutput(); co.Code = input.Code; co.Output = CompileHelper.CompileAndRun(input.Code, input.Language); co.Id = input.Id; return(co); }
public ActionResult Save(CodeViewModel vm) { _logRepository.Insert(new Log { InputCode = vm.InputCode, IpAddress = Request.UserHostAddress }); string id = null; if (!string.IsNullOrEmpty(vm.Id)) { var fiddle = _fiddleRepository.Get(vm.Id); if (fiddle != null) { id = fiddle.Id; } } if (id == null) { const string hashOptions = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var random = new Random(); id = new string( Enumerable.Repeat(hashOptions, 8) .Select(s => s[random.Next(s.Length)]) .ToArray()); } var result = CompileHelper.CompileAndRun(vm.InputCode); _fiddleRepository.Insert(new Fiddle { InputCode = vm.InputCode, Id = id, Result = result }); return(new JsonResult { Data = new { id, result } }); }