Пример #1
0
 /// <summary>
 /// Initializes a new instance of the MyHost class. Keep
 /// a reference to the host application object so that it 
 /// can be informed of when to exit.
 /// </summary>
 /// <param name="program">
 /// A reference to the host application object.
 /// </param>
 public MyHost(PSListenerConsoleSample program)
 {
     this.program = program;
     this.myHostUserInterface = new MyHostUserInterface(this.currentOutput);
 }
        /// <summary>
        /// Creates and initiates the listener.
        /// </summary>
        /// <param name="args">The parameter is not used</param>
        private static void Main(string[] args)
        {
            // Display the welcome message.
            Console.Title = "Windows PowerShell Console Host Application Sample";
            ConsoleColor oldFg = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("    Windows PowerShell Console Host Interactive Sample");
            Console.WriteLine("    ==================================================");
            Console.WriteLine(string.Empty);
            Console.WriteLine("This is an example of a simple interactive console host that uses ");
            Console.WriteLine("the Windows PowerShell engine to interpret commands.");
            Console.WriteLine("Type 'exit' to exit.");
            Console.WriteLine(string.Empty);
            Console.ForegroundColor = oldFg;

            // Create the listener and run it. This never returns.
            PSListenerConsoleSample listener = new PSListenerConsoleSample();
            listener.Run();
        }