public string Run(RundotnetData data)
{
Compression.SetCompression();
JavaScriptSerializer json = new JavaScriptSerializer();
if (!string.IsNullOrEmpty(data.Program) && data.Program.Length > 200000)
{
return(json.Serialize(new JsonData()
{
Errors = "Program is too long (max is 200000 characters).\n"
}));
}
data.Warnings = new List <string>();
data.Errors = new List <string>();
data = RundotnetLogic.RunProgram(data);
string warnings = null, errors = null;
if (data.Warnings.Count() != 0 && data.ShowWarnings)
{
warnings = data.Warnings.Aggregate((a, b) => a + "\n" + b);
}
if (data.Errors.Count() != 0)
{
errors = data.Errors.Aggregate((a, b) => a + "\n" + b);
}
return(json.Serialize(new JsonData()
{
Warnings = warnings, Errors = errors, Result = data.Output, Stats = data.RunStats
}));
}