/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="config"></param>
 /// <param name="attr"></param>
 /// <param name="httpClientFactory"></param>
 public EventGridOutputAsyncCollector(EventGridOutputConfiguration config, EventGridOutputAttribute attr, IHttpClientFactory httpClientFactory)
 {
     this.config            = config;
     this.attr              = attr;
     this.httpClientFactory = httpClientFactory;
     this.eventGridEvents   = new List <AzureEventGridEvent>();
 }
        /// <summary>
        /// Combine <see cref="HttpCallMessage"/> with <see cref="HttpCallConfiguration"/> and <see cref="HttpCallAttribute"/>
        /// </summary>
        /// <param name="message"></param>
        /// <param name="config"></param>
        /// <param name="attr"></param>
        /// <returns></returns>
        private static AzureEventGridEvent CreateEventGridEvent(EventGridOutput @event, EventGridOutputConfiguration config, EventGridOutputAttribute attr)
        {
            var eventType = Utils.MergeValueForProperty(@event.EventType, config.EventType, attr.EventType);

            if (string.IsNullOrEmpty(eventType))
            {
                throw new ArgumentException("Event Grid event type is missing", nameof(eventType));
            }

            var subject = Utils.MergeValueForProperty(@event.Subject, config.Subject, attr.Subject);

            if (string.IsNullOrEmpty(subject))
            {
                throw new ArgumentException("Event Grid event subject is missing", nameof(subject));
            }


            var eventGridEvent = new AzureEventGridEvent(@event.Data, eventType, subject);

            // optional: data version
            var dataVersion = Utils.MergeValueForProperty(@event.DataVersion, config.DataVersion, attr.DataVersion);

            if (!string.IsNullOrEmpty(dataVersion))
            {
                eventGridEvent.DataVersion = dataVersion;
            }

            return(eventGridEvent);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="config"></param>
 /// <param name="attr"></param>
 public EventGridOutputAsyncCollector(EventGridOutputConfiguration config, EventGridOutputAttribute attr) : this(config, attr, HttpClientFactory.Instance)
 {
 }