CodeCompiler.cs 768 B

12345678910111213141516171819202122232425
  1. using Microsoft.CSharp;
  2. using System.CodeDom.Compiler;
  3. namespace IntelligentControlForsx.CodeGenerator
  4. {
  5. public class CodeCompiler
  6. {
  7. public static CodeCompilerResults CompileModelCode(string clsName, string[] varArray)
  8. {
  9. CodeDomProvider cpd = new CSharpCodeProvider();
  10. CompilerParameters cp = new CompilerParameters();
  11. cp.ReferencedAssemblies.Add("System.dll");
  12. cp.ReferencedAssemblies.Add("GdxnyWindTurbineContorls.exe");
  13. cp.GenerateExecutable = false;
  14. string sourceCode = CodeGenerator.Generate(clsName, varArray);
  15. CompilerResults cr = cpd.CompileAssemblyFromSource(cp, sourceCode);
  16. return new CodeCompilerResults(cr);
  17. }
  18. }
  19. }