private IReadOnlyDictionary <string, object> CreateBindingData(QueueMessage value,
                                                                       IReadOnlyDictionary <string, object> bindingDataFromValueType)
        {
            Dictionary <string, object> bindingData = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);

            string queueMessageString = value.TryGetAsString(_logger);

            // Don't provide the QueueTrigger binding data when the queue message is not a valid string.
            if (queueMessageString != null)
            {
                bindingData.Add("QueueTrigger", queueMessageString);
            }

            bindingData.Add("DequeueCount", value.DequeueCount);
            bindingData.Add("ExpirationTime", value.ExpiresOn.GetValueOrDefault(DateTimeOffset.MaxValue));
            bindingData.Add("Id", value.MessageId);
            bindingData.Add("InsertionTime", value.InsertedOn.GetValueOrDefault(DateTimeOffset.UtcNow));
            bindingData.Add("NextVisibleTime", value.NextVisibleOn.GetValueOrDefault(DateTimeOffset.MaxValue));
            bindingData.Add("PopReceipt", value.PopReceipt);

            if (bindingDataFromValueType != null)
            {
                foreach (KeyValuePair <string, object> item in bindingDataFromValueType)
                {
                    // In case of conflict, binding data from the value type overrides the built-in binding data above.
                    bindingData[item.Key] = item.Value;
                }
            }

            return(bindingData);
        }
        public Guid?GetOwner(QueueMessage msg)
        {
            string text = msg.TryGetAsString(_logger);

            if (text == null)
            {
                return(null);
            }

            IDictionary <string, JToken> json;

            try
            {
                json = JsonSerialization.ParseJObject(text);
            }
            catch (Exception)
            {
                return(null);
            }

            if (json == null || !json.ContainsKey(ParentGuidFieldName) || json[ParentGuidFieldName].Type != JTokenType.String)
            {
                return(null);
            }

            string val = (string)json[ParentGuidFieldName];

            Guid guid;

            if (Guid.TryParse(val, out guid))
            {
                return(guid);
            }
            return(null);
        }
 public string ToInvokeString()
 {
     return(_message.TryGetAsString(_logger));
 }