internal void AddListener(GraphWebhookTriggerAttribute attribute, WebhookTriggerListener listener)
        {
            if (attribute.ResourceType == null)
            {
                if (_generalListener == null)
                {
                    throw new InvalidOperationException($"Cannot have multiple graph webhook listeners without types.");
                }

                _generalListener = listener;
            }
            else
            {
                if (_listenerPerDataType.ContainsKey(attribute.ResourceType))
                {
                    throw new InvalidOperationException($"Cannot have more than one graph webhook listener for {attribute.ResourceType}");
                }
                _listenerPerDataType.Add(attribute.ResourceType, listener);
            }
        }
        // Called by external webhook to push data.
        public async Task PushDataAsync(WebhookTriggerData data)
        {
            WebhookTriggerListener dataListener = _generalListener;

            if (_listenerPerDataType.ContainsKey(data.odataType))
            {
                dataListener = _listenerPerDataType[data.odataType];
            }

            if (dataListener != null)
            {
                var exec = dataListener.Executor;

                TriggeredFunctionData input = new TriggeredFunctionData
                {
                    ParentId     = null,
                    TriggerValue = data,
                };
                FunctionResult result = await exec.TryExecuteAsync(input, CancellationToken.None);
            }
        }
 internal void StopListeners()
 {
     _listenerPerDataType.Clear();
     _generalListener = null;
 }
 public WebhookTriggerBindingProvider()
 {
     _generalListener = null;
 }
            public Task <IListener> CreateListenerAsync(ListenerFactoryContext context)
            {
                var listener = new WebhookTriggerListener(context, _parent, _attribute);

                return(Task.FromResult <IListener>(listener));
            }