예제 #1
0
 public static string PropertyOrDefault(this TransactionAdaptionEventModel @event, string key)
 {
     if (@event?.Properties == null)
     {
         return(null);
     }
     return(@event.Properties.TryGetValue(key, out var v) ? v : null);
 }
        /// <summary>
        /// Determines whether the file contains the event and sets the output parameter to the event
        /// </summary>
        /// <param name="eventId">Event to look for</param>
        /// <param name="adaptionEvent">The output parameter</param>
        /// <returns>True if it was found, false otherwise</returns>
        public bool TryGetEvent(EventId eventId, out TransactionAdaptionEventModel adaptionEvent)
        {
            if (_eventLookup.ContainsKey(eventId))
            {
                adaptionEvent = _eventLookup[eventId];
            }
            else
            {
                adaptionEvent = Events.EventOrDefault(eventId);
                _eventLookup.Add(eventId, adaptionEvent);
            }

            return(adaptionEvent != null);
        }
예제 #3
0
        public static TEnum?PropertyOrDefault <TEnum>(this TransactionAdaptionEventModel @event, string key) where TEnum : struct
        {
            if (@event?.Properties == null)
            {
                return(null);
            }

            var couldGetValue = @event.Properties.TryGetValue(key, out var v);

            if (!couldGetValue)
            {
                return(null);
            }

            if (!Enum.TryParse(v, true, out TEnum val))
            {
                return(null);
            }

            return(val);
        }