/// <summary> /// Creates a rich console progress monitor provider. /// </summary> /// <param name="console">The console to which messages should be written.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="console"/> is null.</exception> public RichConsoleProgressMonitorProvider(IRichConsole console) { if (console == null) throw new ArgumentNullException(@"console"); this.console = console; }
/// <summary> /// Creates a logger. /// </summary> /// <param name="console">The console.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="console"/> is null.</exception> public RichConsoleLogger(IRichConsole console) { if (console == null) throw new ArgumentNullException(@"console"); this.console = console; }
/// <summary> /// Creates a utility command context. /// </summary> /// <param name="arguments">The parsed command line arguments.</param> /// <param name="console">The console.</param> /// <param name="logger">The logger.</param> /// <param name="progressMonitorProvider">The progress monitor provider.</param> /// <param name="verbosity">The verbosity.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="arguments"/>, /// <paramref name="console"/>, <paramref name="logger"/> or <paramref name="progressMonitorProvider"/> is null.</exception> public UtilityCommandContext(object arguments, IRichConsole console, ILogger logger, IProgressMonitorProvider progressMonitorProvider, Verbosity verbosity) { if (arguments == null) { throw new ArgumentNullException("arguments"); } if (console == null) { throw new ArgumentNullException("console"); } if (logger == null) { throw new ArgumentNullException("logger"); } if (progressMonitorProvider == null) { throw new ArgumentNullException("progressMonitorProvider"); } this.arguments = arguments; this.console = console; this.logger = logger; this.progressMonitorProvider = progressMonitorProvider; this.verbosity = verbosity; }
/// <summary> /// Creates a logger. /// </summary> /// <param name="console">The console.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="console"/> is null.</exception> public RichConsoleLogger(IRichConsole console) { if (console == null) { throw new ArgumentNullException(@"console"); } this.console = console; }
/// <summary> /// Creates a console presenter for a progress monitor. /// </summary> /// <param name="console">The console.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="console"/> is null.</exception> public RichConsoleProgressMonitorPresenter(IRichConsole console) { if (console == null) { throw new ArgumentNullException("console"); } this.console = console; }
protected override void EndProcessing() { // release only in OutWPFCommand //if (_windowCount == 0) //{ _window = null; _dispatcher = null; _xamlUI = null; _windowCount--; //} base.EndProcessing(); }
/// <summary> /// Creates a utility command context. /// </summary> /// <param name="arguments">The parsed command line arguments.</param> /// <param name="console">The console.</param> /// <param name="logger">The logger.</param> /// <param name="progressMonitorProvider">The progress monitor provider.</param> /// <param name="verbosity">The verbosity.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="arguments"/>, /// <paramref name="console"/>, <paramref name="logger"/> or <paramref name="progressMonitorProvider"/> is null.</exception> public UtilityCommandContext(object arguments, IRichConsole console, ILogger logger, IProgressMonitorProvider progressMonitorProvider, Verbosity verbosity) { if (arguments == null) throw new ArgumentNullException("arguments"); if (console == null) throw new ArgumentNullException("console"); if (logger == null) throw new ArgumentNullException("logger"); if (progressMonitorProvider == null) throw new ArgumentNullException("progressMonitorProvider"); this.arguments = arguments; this.console = console; this.logger = logger; this.progressMonitorProvider = progressMonitorProvider; this.verbosity = verbosity; }
/// <summary> /// Runs the program. /// </summary> /// <param name="console">The console.</param> /// <param name="args">The command-line arguments.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="console"/> /// or <paramref name="args"/> is null.</exception> /// <exception cref="InvalidOperationException">Thrown if the program has already started running.</exception> public int Run(IRichConsole console, string[] args) { if (console == null) { throw new ArgumentNullException("console"); } if (args == null) { throw new ArgumentNullException("args"); } if (this.console != null) { throw new InvalidOperationException("The program has already started running."); } this.console = console; commandLineOutput = new CommandLineOutput(console); try { if (!console.IsRedirected) { console.Title = ApplicationTitle; } return(RunImpl(args)); } catch (Exception ex) { return(HandleFatalException(ex)); } finally { console.ResetColor(); } }
// private Huddled.WPF.Controls.Interfaces.IPSXamlConsole xamlUI; // private FlowDocument _document = null; #region Methods protected override void BeginProcessing() { if (_window == null) { _template = GetXaml(); if (Host.PrivateData != null && Host.PrivateData.BaseObject is Options) { //((IPSWpfHost)).GetWpfConsole(); _xamlUI = ((Options)Host.PrivateData.BaseObject).WpfConsole as PoshConsole; if (Popup.ToBool()) { //_window = new Window //{ // WindowStyle = WindowStyle.ToolWindow, // // Content = XamlHelper.NewItemsControl() //}; //_xamlUI.PopoutWindows.Add(_window); //_window.Show(); //_dispatcher = _window.Dispatcher; ////////////////////////////////////////////////////////////// // If they ask for a popup from a IPSWpfOptions, we still use the Presentation // That way the threading "issues" are the same for both Wpf and non-Wpf hosts // Otherwise we'd have to deal with two different realities var result = Presentation.Start(_template, null, null); _window = result.Window; _dispatcher = result.Dispatcher; } else { //_window = _xamlUI.RootWindow; _dispatcher = _xamlUI.Dispatcher; _xamlUI.RootWindow.LoadTemplates(); } } else { var result = Presentation.Start(_template, null, null); _window = result.Window; _dispatcher = result.Dispatcher; } if (_template != null) { var error = _dispatcher.Invoke(() => { ErrorRecord err; _template.TryLoadXaml(out _element, out err); var window = _element as Window; if (window != null) { if (Host.PrivateData?.BaseObject is IPSWpfOptions) { _window = window; _window.Show(); _dispatcher = _window.Dispatcher; } _element = null; } return(err); }); if (error != null) { WriteError(error); } } } // internal reference count _windowCount++; base.BeginProcessing(); }
/// <summary> /// Initializes new instance of CommandLineOutput. /// </summary> ///<param name="console">The console.</param> public CommandLineOutput(IRichConsole console) : this(console.Out, console.Width) { }
protected override void BeginProcessing() { if (_window == null) { _template = GetXaml(); if (Host.PrivateData != null && Host.PrivateData.BaseObject is Options) { //((IPSWpfHost)).GetWpfConsole(); _xamlUI = ((Options)Host.PrivateData.BaseObject).WpfConsole as PoshConsole; if (Popup.ToBool()) { //_window = new Window //{ // WindowStyle = WindowStyle.ToolWindow, // // Content = XamlHelper.NewItemsControl() //}; //_xamlUI.PopoutWindows.Add(_window); //_window.Show(); //_dispatcher = _window.Dispatcher; ////////////////////////////////////////////////////////////// // If they ask for a popup from a IPSWpfOptions, we still use the Presentation // That way the threading "issues" are the same for both Wpf and non-Wpf hosts // Otherwise we'd have to deal with two different realities var result = Presentation.Start(_template, null, null); _window = result.Window; _dispatcher = result.Dispatcher; } else { //_window = _xamlUI.RootWindow; _dispatcher = _xamlUI.Dispatcher; _xamlUI.RootWindow.LoadTemplates(); } } else { var result = Presentation.Start(_template, null, null); _window = result.Window; _dispatcher = result.Dispatcher; } if (_template != null) { var error = _dispatcher.Invoke(() => { ErrorRecord err; _template.TryLoadXaml(out _element, out err); var window = _element as Window; if (window != null) { if (Host.PrivateData?.BaseObject is IPSWpfOptions) { _window = window; _window.Show(); _dispatcher = _window.Dispatcher; } _element = null; } return err; }); if (error != null) { WriteError(error); } } } // internal reference count _windowCount++; base.BeginProcessing(); }