/// <summary> /// initialize contextual attributes and setup the context streams /// </summary> /// <param name="commandEvaluationContext">context</param> public void Initialize(CommandEvaluationContext commandEvaluationContext) { this.CommandEvaluationContext = commandEvaluationContext; // TODO: activate after DotNetConsole is no more static - see remarks below /* * Out = new ConsoleTextWriterWrapper(System.Console.Out); * Err = new TextWriterWrapper(System.Console.Error); * In = System.Console.In; */ var scriptOptions = ScriptOptions.Default; var abl = Assembly.GetExecutingAssembly(); scriptOptions = scriptOptions.WithReferences(abl); var cSharpScriptEngine = new CSharpScriptEngine( commandEvaluationContext.CommandLineProcessor.Console, scriptOptions); Out = new ShellConsoleTextWriterWrapper( commandEvaluationContext, System.Console.Out, cSharpScriptEngine ) { IsMute = commandEvaluationContext.Out.IsMute }; commandEvaluationContext.CommandLineProcessor.Console.Out = Out; // are trully equals Err = commandEvaluationContext.CommandLineProcessor.Console.Err; In = commandEvaluationContext.CommandLineProcessor.Console.In; commandEvaluationContext.SetStreams(Out, In, Err); }
/// <summary> /// initialize contextual attributes and setup the context streams /// </summary> /// <param name="commandEvaluationContext">context</param> public void Initialize(CommandEvaluationContext commandEvaluationContext) { this.CommandEvaluationContext = commandEvaluationContext; // TODO: activate after DotNetConsole is no more static - see remarks below /* * Out = new ConsoleTextWriterWrapper(System.Console.Out); * Err = new TextWriterWrapper(System.Console.Error); * In = System.Console.In; */ var scriptOptions = ScriptOptions.Default; var abl = Assembly.GetExecutingAssembly(); scriptOptions = scriptOptions.WithReferences(abl); var cSharpScriptEngine = new CSharpScriptEngine(scriptOptions); //Out = DotNetConsole.Out; Out = new ShellConsoleTextWriterWrapper( commandEvaluationContext, System.Console.Out, cSharpScriptEngine ); /* * it can exists only one wrapper for out, * between the command evaluation context and dot net console */ DotNetConsole.Out = Out; Err = DotNetConsole.Err; In = DotNetConsole.In; commandEvaluationContext.SetStreams(Out, In, Err); }