/// <summary>
 /// Gets whether or not the event is a System defined event and returns the deserialized
 /// system event via out parameter.
 /// </summary>
 /// <param name="eventData">If the event is a system event, this will be populated
 /// with the deserialized system event. Otherwise, this will be null.</param>
 /// <returns> Whether or not the event is a system event.</returns>
 public bool TryGetSystemEventData(out object eventData)
 {
     try
     {
         JsonDocument requestDocument = JsonDocument.Parse(Data.ToMemory());
         eventData = SystemEventExtensions.AsSystemEventData(EventType, requestDocument.RootElement);
         return(eventData != null);
     }
     catch
     {
         eventData = null;
         return(false);
     }
 }
        /// <summary>
        /// Gets whether or not the event is a System defined event and returns the deserialized
        /// system event data via out parameter.
        /// </summary>
        /// <param name="cloudEvent"></param>
        /// <param name="eventData">If the event is a system event, this will be populated
        /// with the deserialized system event data. Otherwise, this will be null.</param>
        /// <returns> Whether or not the event is a system event.</returns>
        public static bool TryGetSystemEventData(this CloudEvent cloudEvent, out object eventData)
        {
            BinaryData data = cloudEvent.Data;

            try
            {
                JsonDocument requestDocument = JsonDocument.Parse(data.ToMemory());
                eventData = SystemEventExtensions.AsSystemEventData(cloudEvent.Type, requestDocument.RootElement);
                return(eventData != null);
            }
            catch
            {
                eventData = null;
                return(false);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Deserializes a system event to its system event data payload. This will return null if the event is not a system event.
 /// To detect whether an event is a system event, use the <see cref="IsSystemEvent"/> property.
 /// </summary>
 /// <returns>The rich system model type.</returns>
 public object AsSystemEventData() =>
 SystemEventExtensions.AsSystemEventData(EventType, SerializedData);
 /// <summary>
 /// Gets whether or not the event is a System defined event and returns the deserialized
 /// system event via out parameter.
 /// </summary>
 /// <param name="eventData">If the event is a system event, this will be populated
 /// with the deserialized system event. Otherwise, this will be null.</param>
 /// <returns> Whether or not the event is a system event.</returns>
 public bool TryGetSystemEventData(out object eventData)
 {
     eventData = SystemEventExtensions.AsSystemEventData(EventType, SerializedData);
     return(eventData != null);
 }