Boo.Lang.Compiler.BooCompiler.Run C# (CSharp) Метод

Run() публичный Метод

public Run ( Boo.Lang.Compiler.Ast.CompileUnit compileUnit ) : CompilerContext
compileUnit Boo.Lang.Compiler.Ast.CompileUnit
Результат CompilerContext
        public CompilerContext Run(CompileUnit compileUnit)
        {
            if (null == compileUnit)
            {
                throw new ArgumentNullException("compileUnit");
            }
            if (null == _parameters.Pipeline)
            {
                throw new InvalidOperationException(Boo.Lang.ResourceManager.GetString("BooC.CantRunWithoutPipeline"));
            }
            CompilerContext context = new CompilerContext(_parameters, compileUnit);
            _parameters.Pipeline.Run(context);
            return context;
        }

Same methods

BooCompiler::Run ( ) : CompilerContext

Usage Example

        public void Run(string text)
        {
            BooCompiler compiler = new BooCompiler();
            compiler.Parameters.Ducky = true;
            compiler.Parameters.Pipeline = new CompileToMemory();
            compiler.Parameters.Input.Add(new StringInput("Script", text));

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                compiler.Parameters.References.Add(assembly);
            }

            CompilerContext context = compiler.Run();

            if (context.GeneratedAssembly == null)
            {
                if (context.Errors.Count > 0)
                {
                    errors = context.Errors.ToString(true);
                }
                return;
            }

            try
            {
                Type[] types = context.GeneratedAssembly.GetTypes();
                Type scriptModule = types[types.Length - 1];
                MethodInfo mainEntry = scriptModule.Assembly.EntryPoint;
                mainEntry.Invoke(null, new object[mainEntry.GetParameters().Length]);
            }
            catch (Exception ex)
            {
                errors = ex.Message;
            }
        }
All Usage Examples Of Boo.Lang.Compiler.BooCompiler::Run