public static void AddData(Message message, string name, Func <string> dataProvider)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name");
            }

            if (dataProvider == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dataProvider");
            }

            CorrelationDataMessageProperty data = null;
            object value = null;

            if (message.Properties.TryGetValue(PropertyName, out value))
            {
                data = value as CorrelationDataMessageProperty;
            }

            bool addNewProperty = false;

            if (data == null)
            {
                data           = new CorrelationDataMessageProperty();
                addNewProperty = true;
            }

            data.Add(name, dataProvider);

            if (addNewProperty)
            {
                message.Properties[PropertyName] = data;
            }
        }
 public static bool TryGet(Message message, out CorrelationDataMessageProperty property)
 {
     if (message == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
     }
     return(TryGet(message.Properties, out property));
 }
 public static bool TryGet(MessageProperties properties, out CorrelationDataMessageProperty property)
 {
     if (properties.TryGetValue(PropertyName, out object value))
     {
         property = value as CorrelationDataMessageProperty;
     }
     else
     {
         property = null;
     }
     return(property != null);
 }