コード例 #1
0
        /// <summary>
        /// <see cref="ScriptExecutorBase.OnExecute(string, ScriptExecutionResult)" />
        /// </summary>
        protected override void OnExecute(string src, ScriptExecutionResult result)
        {
            var compiler = new VBCodeProvider();

            CompilerParameters compilerParams;
            IList <string>     namespaces;

            CompilerHelper.CreateDataForCompiler(out compilerParams,
                                                 out namespaces);

            string typeName;
            var    compilerResult = compiler.CompileAssemblyFromSource(compilerParams,
                                                                       this.CreateFullSourceCode(src, namespaces, out typeName));

            if (compilerResult.Errors.HasErrors == false)
            {
                var type = compilerResult.CompiledAssembly
                           .GetTypes()
                           .Single(x => x.FullName == typeName);

                var env = (global::MarcelJoachimKloubert.ScriptTHOR.Scripting.ScriptExecutionEnvironmentBase)Activator.CreateInstance(type);

                var ctx = new ScriptExecutionContext();
                env.Execute(ctx);
            }
            else
            {
            }
        }