using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Microsoft.CSharp;
using System.CodeDom.Compiler;
using System.IO;
namespace linqtosql
{
class CodeDriver: MarshalByRefObject
{
private string prefix =
"using System; "
+
"using System.Text;"
+
"using System.Collections.Generic;"
+
"using linqtosql;"
+
"public static class Driver:"
+
"{"
+
"public static void Run()"
+
"{"
+
"DataClassesNorthwinDataContext db = new DataClassesNorthwinDataContext();"
;
private string postfix =
"}"
+
"}"
;
public string CompileAndRun(string input, out bool hasError)
{
Form1 f= new Form1();
hasError = false;
string returnData = null;
CompilerResults results = null;
using (CSharpCodeProvider provider = new CSharpCodeProvider())
{
CompilerParameters options = new CompilerParameters();
options.GenerateInMemory = true;
StringBuilder sb = new StringBuilder();
sb.Append(prefix);
sb.Append(input);
sb.Append(postfix);
results = provider.CompileAssemblyFromSource(options, sb.ToString());
}
if (results.Errors.HasErrors)
{