123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using System;
- using System.CodeDom.Compiler;
- using System.Collections.Specialized;
- using System.Reflection;
- namespace IntelligentControlForsx.CodeGenerator
- {
- public class CodeCompilerResults
- {
- private CompilerResults compilerResults;
- public CodeCompilerResults(CompilerResults results)
- {
- compilerResults = results;
- }
- public bool HasErrors
- {
- get
- {
- if (compilerResults == null ||
- compilerResults.Errors == null)
- return false;
- return compilerResults.Errors.HasErrors;
- }
- }
- public bool HasWarnings
- {
- get
- {
- if (compilerResults == null ||
- compilerResults.Errors == null)
- return false;
- return compilerResults.Errors.HasWarnings;
- }
- }
- public string ErrorText
- {
- get
- {
- if (this.HasErrors)
- {
- string msg = string.Empty;
- foreach (CompilerError ce in compilerResults.Errors)
- {
- if (ce.IsWarning)
- continue;
- msg += ce.ErrorText;
- }
- return msg;
- }
- return null;
- }
- }
- public string WarningText
- {
- get
- {
- if (this.HasWarnings)
- {
- string msg = string.Empty;
- foreach (CompilerError ce in compilerResults.Errors)
- {
- if (ce.IsWarning)
- msg += ce.ErrorText;
- }
- return msg;
- }
- return null;
- }
- }
- public Assembly ResultAssembly
- {
- get
- {
- if (compilerResults != null)
- return compilerResults.CompiledAssembly;
- return null;
- }
- }
- public StringCollection Output
- {
- get
- {
- if (compilerResults != null)
- return compilerResults.Output;
- return null;
- }
- }
- public TableModel CreateTableModel(string deviceId)
- {
- if (this.ResultAssembly != null)
- {
- Type fType = ResultAssembly.GetTypes()[0];
- return (TableModel)ResultAssembly.CreateInstance(fType.FullName, false, BindingFlags.Default, null, new object[] { deviceId }, null, null);
- }
- return null;
- }
- }
- }
|