Beispiel #1
0
        private string GetValidationResult(Stream requestStream)
        {
            var compiler = new CSharpValidator(new CSharpCompilationProvider());
            var serializer = new JavaScriptSerializer();

            SourceCode sourceCode;
            using (var reader = new StreamReader(requestStream))
            {
                var foo = reader.ReadToEnd();
                sourceCode = serializer.Deserialize<SourceCode>(foo);
            }

            var errors = compiler.GetCompilationErrors(sourceCode)
                .Where(x => x.Info.Severity > DiagnosticSeverity.Warning)
                .Select(x => new
                {
                    Location = x.Location.GetLineSpan(true),
                    Message = x.Info.GetMessage(),
                });

            return serializer.Serialize(new { status = "ok", data = errors });
        }
Beispiel #2
0
        private string GetValidationResult(Stream requestStream)
        {
            var compiler   = new CSharpValidator(new CSharpCompilationProvider());
            var serializer = new JavaScriptSerializer();

            SourceCode sourceCode;

            using (var reader = new StreamReader(requestStream))
            {
                var foo = reader.ReadToEnd();
                sourceCode = serializer.Deserialize <SourceCode>(foo);
            }

            var errors = compiler.GetCompilationErrors(sourceCode)
                         .Where(x => x.Info.Severity > DiagnosticSeverity.Warning)
                         .Select(x => new
            {
                Location = x.Location.GetLineSpan(true),
                Message  = x.Info.GetMessage(),
            });

            return(serializer.Serialize(new { status = "ok", data = errors }));
        }
Beispiel #3
0
 public HomeController(IPostRepository contentRepository)
 {
     db       = contentRepository;
     compiler = new CSharpValidator(new CSharpCompilationProvider());
 }