Beispiel #1
0
        public ActionResult Index()
        {
            var post = BuildSamplePost();

            var errors = compiler.GetCompilationErrors(post)
                         .Select(x => new EditorError
            {
                Location = x.Location.GetLineSpan(true),
                Message  = x.Info.GetMessage()
            });

            var viewModel = new PostViewModel(post)
            {
                Errors = errors
            };

            return(View("Show", viewModel));
        }
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
        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 }));
        }