Partager via


EventData Class

Definition

Represents the data in signaled event.

[System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.App.Runtime.EventDataConverter))]
public class EventData : EventArgs
[<System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.App.Runtime.EventDataConverter))>]
type EventData = class
    inherit EventArgs
Public Class EventData
Inherits EventArgs
Inheritance
EventData
Derived
Attributes

Remarks

In PowerShell, we add on the EventDataConverter to support sending events between modules. Obviously, this code would need to be duplcated on both modules. This is preferable to sharing a common library, as versioning makes that problematic.

Constructors

EventData()

Fields

Cancel

Cancellation method for this event.

If the event consumer wishes to cancel the request that initiated this event, call Cancel()

ExtendedData

Any extended data for an event should be serialized and stored here.

Id

The type of the event being signaled

Message

The user-ready message from the event.

Parameter

When the event is about a parameter, this is the parameter name. Used in Validation Events

RequestMessage

If the event triggers after the request message has been created, this will contain the Request Message (which in HTTP calls would be HttpRequestMessage)

Typically you'd cast this to the expected type to use it:

if(eventData.RequestMessgae is HttpRequestMessage httpRequest) 
{
  httpRequest.Headers.Add("x-request-flavor", "vanilla");
}
ResponseMessage

If the event triggers after the response is back, this will contain the Response Message (which in HTTP calls would be HttpResponseMessage)

Typically you'd cast this to the expected type to use it:

if(eventData.ResponseMessage is HttpResponseMessage httpResponse){
  var flavor = httpResponse.Headers.GetValue("x-request-flavor");
}
Value

This represents a numeric value associated with the event. Use for progress-style events

Applies to