public int Execute(TaskConsoleParameters args) { var context = BSharpCompiler.CompileDirectory(args.ScriptDirectory, new BSharpConfig { Global = new Scope(args.Global), KeepLexInfo = true }); var cls = context[args.ScriptClass]; if (null == cls) { throw new Exception("cannot find class " + args.ScriptClass); } var container = ContainerFactory.CreateDefault(); container.RegisterAssembly(typeof(TaskProcess).Assembly); var configProvider = new GenericConfiguration(cls.Compiled, context) { Custom = args }; container.Set <IConfigProvider>(configProvider); Loggy.Manager = container.Get <ILoggyManager>(); var defloggy = Loggy.Manager.Get(); defloggy.Level = args.LogLevel; var consoleAppender = defloggy.Appenders.OfType <ConsoleAppender>().FirstOrDefault(); if (null == consoleAppender) { defloggy.Appenders.Add(new ConsoleAppender { Format = args.LogFormat, Level = args.LogLevel, Manager = Loggy.Manager }); } else { consoleAppender.Format = args.LogFormat; consoleAppender.Level = args.LogLevel; } var loggy = Loggy.Manager.Get("bcinst"); var installRequest = new TaskEnvironment { Config = cls.Compiled, Context = context, Log = loggy, Globals = new Scope(args.Global), Targets = args.Targets.ToArray() }; var processor = container.Get <ITaskProcessor>(); processor.Execute(installRequest); return(0); }
//[TestCase(60)] //[TestCase(70)] //[TestCase(80)] //[TestCase(90)] //[TestCase(100)] public void ChartsCompileMultTimesTestForPerformanceControl(int times) { Console.WriteLine(Process.GetCurrentProcess().Threads.Count); for (var i = 0; i < times; i++) { Console.Write(i); BSharpCompiler.CompileDirectory(@"C:\z3projects\assoi\local\Draft\report\content\charts"); Console.Write(":"); Console.Write(Process.GetCurrentProcess().Threads.Count); Console.Write(", "); } }
protected override void InternalExecute(IScope scope) { var dir = Interpolate(Directory, scope); if (dir.Contains("@")) { dir = EnvironmentInfo.ResolvePath(dir); } if (!Path.IsPathRooted(dir)) { var fileDir = Path.GetDirectoryName(Config.Describe().File); dir = Path.GetFullPath(Path.Combine(fileDir, dir)); } var context = BSharpCompiler.CompileDirectory(dir, new BSharpConfig { Global = new Scope(scope), KeepLexInfo = true }); if (TaskScope == TaskScope.Environment) { Environment.Context.Merge(context); } else { var _scope = ResolveScope(TaskScope, scope); var scopedContext = _scope.Get <IBSharpContext>("bscontext"); if (null != scopedContext) { scopedContext.Merge(context); } else { _scope["bscontext"] = context; } } L.Trace("B# classes from " + dir + " merged at level " + TaskScope + " : " + context.Get(BSharpContextDataType.Working).Count() + " classes total"); }