public CompilerResults CompileAssemblyFromFileBatch(CompilerParameters options, string[] fileNames) { string tempFile; ArrayList classlessFiles = new ArrayList(); ArrayList files = new ArrayList(); int count = 0; CCSharpParser ccs; foreach (string file in fileNames) { ccs = new CCSharpParser(file); if (!ccs.isClassless) { files.Add(file); } else { tempFile = ccs.ToTempFile(count > 0); classlessFiles.Add(tempFile); files.Add(tempFile); } count++; } Microsoft.CSharp.CSharpCodeProvider provider; if (options.ToString() == "" || options == null) { return(new Microsoft.CSharp.CSharpCodeProvider().CreateCompiler().CompileAssemblyFromFileBatch(options, fileNames)); } else { return(new Microsoft.CSharp.CSharpCodeProvider(new Dictionary <string, string>() { { "CompilerVersion", options.ToString() } }).CreateCompiler().CompileAssemblyFromFileBatch(options, fileNames)); } CompilerResults retval; retval = provider.CreateCompiler().CompileAssemblyFromFileBatch(options, (string[])files.ToArray(typeof(string))); if (!retval.Errors.HasErrors) { foreach (string file in classlessFiles) { try { File.Delete(file); } catch {} } } return(retval); }
static void i_Main() { CCSharpParser ccs = new CCSharpParser(@"C:\cs-script\Dev\CC#\using.ccs"); if (ccs.isClassless) { Console.WriteLine("CC#"); Console.WriteLine(ccs.CSharpCode); } else { Console.WriteLine("C#"); } }
static void Main(string[] args) { string[] files = new[] { @"E:\cs-script\Samples\hello.cpp" }; var cParams = new CompilerParameters(); cParams.OutputAssembly = @"C:\Users\osh\AppData\Local\Temp\CSSCRIPT\Cache\-727015236\hello.cpp.dll"; cParams.ReferencedAssemblies.Add(@"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"); cParams.ReferencedAssemblies.Add(@"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Linq\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Linq.dll"); cParams.ReferencedAssemblies.Add(@"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll"); var compiler = new CPPCompiler(); compiler.CompileAssemblyFromFileBatch(cParams, files); var parser = new CCSharpParser(@"E:\cs-script\engine\CSSCodeProvider.v3.5\Script.cs"); parser.ToTempFile(false); }
public CompilerResults CompileAssemblyFromFileBatch(CompilerParameters options, string[] fileNames) { string tempFile; ArrayList classlessFiles = new ArrayList(); ArrayList files = new ArrayList(); int count = 0; CCSharpParser ccs; foreach (string file in fileNames) { ccs = new CCSharpParser(file); if (!ccs.isClassless) { files.Add(file); } else { tempFile = ccs.ToTempFile(count > 0 ); classlessFiles.Add(tempFile); files.Add(tempFile); } count++; } Microsoft.CSharp.CSharpCodeProvider provider; if (options.ToString() == "" || options == null) return new Microsoft.CSharp.CSharpCodeProvider().CreateCompiler().CompileAssemblyFromFileBatch(options, fileNames); else return new Microsoft.CSharp.CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", options.ToString() } }).CreateCompiler().CompileAssemblyFromFileBatch(options, fileNames); CompilerResults retval; retval = provider.CreateCompiler().CompileAssemblyFromFileBatch(options, (string[])files.ToArray(typeof(string))); if (!retval.Errors.HasErrors) foreach (string file in classlessFiles) try { File.Delete(file); } catch{} return retval; }
public CompilerResults CompileAssemblyFromFileBatch(CompilerParameters options, string[] fileNames) { string tempFile; ArrayList classlessFiles = new ArrayList(); ArrayList files = new ArrayList(); int count = 0; CCSharpParser ccs; foreach (string file in fileNames) { ccs = new CCSharpParser(file); if (!ccs.isClassless) { files.Add(file); } else { tempFile = ccs.ToTempFile(count > 0 ); classlessFiles.Add(tempFile); files.Add(tempFile); } count++; } CompilerResults retval; retval = (new Microsoft.CSharp.CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromFileBatch(options, (string[])files.ToArray(typeof(string))); if (!retval.Errors.HasErrors) foreach (string file in classlessFiles) try { File.Delete(file); } catch{} return retval; }
static void i_Main() { CCSharpParser ccs = new CCSharpParser(@"C:\cs-script\Dev\CC#\using.ccs"); if (ccs.isClassless) { Console.WriteLine("CC#"); Console.WriteLine(ccs.CSharpCode); } else Console.WriteLine("C#"); }
static void Main(string[] args) { var parser = new CCSharpParser(@"E:\cs-script\engine\CSSCodeProvider.v3.5\Script.cs"); parser.ToTempFile(false); }