/// <summary>
 /// Raise an event to pass a message back to the parent AppDomain
 /// </summary>
 /// <param name="e">The message in an EventArgs</param>
 public void Message(MessageEventArgs e)
 {
     if (OnMessage != null)
     {
         e.MarshalExceptionToBase();
         OnMessage(this, e);
     }
 }
Пример #2
0
 /// <summary>
 /// Output a message in the appropriate way in a powershell command
 /// </summary>
 /// <param name="caller">the Cmdlet object running</param>
 /// <param name="e">the event containing the message</param>
 public static void Handle(Cmdlet caller, MessageEventArgs e)
 {
     switch (e.MessageType)
     {
         case MessageType.Verbose:
             caller.WriteVerbose(e.Message);
             break;
         case MessageType.Progress:
             caller.WriteProgress(new ProgressRecord(0, e.Activity, e.Message));
             break;
         case MessageType.Error:
             ToolsHelper.WriteException(caller, e.Exception);
             caller.ThrowTerminatingError(new ErrorRecord(e.Exception, "0", ErrorCategory.InvalidOperation, caller));
             break;
         case MessageType.Output:
             caller.WriteObject(e.Message);
             break;
     }
 }
Пример #3
0
 public void SendMessage(MessageEventArgs e)
 {
     MessageHandler.Handle(this, e);
 }