private Dictionary <string, string> ExtractContextProperties(IServiceRemotingRequestMessage message) { IServiceRemotingRequestMessageHeader headers = message.GetHeader(); //DANGER!!! this is using reflection to get to internal dictionary of headers collection. if (getHeadersField == null) { getHeadersField = headers.GetType() .GetFields(BindingFlags.NonPublic | BindingFlags.Instance) .First(f => f.Name == "headers"); } var headersCollection = getHeadersField.GetValue(headers) as Dictionary <string, byte[]>; if (headersCollection == null) { return(null); } var result = headersCollection.ToDictionary( e => e.Key, e => e.Value == null ? null : Enc.GetString(e.Value)); // ActivityId becomes parent here if (result.TryGetValue(KnownProperty.ActivityId, out string activityId)) { result[KnownProperty.ParentActivityId] = activityId; result.Remove(KnownProperty.ActivityId); } return(result); }
private Dictionary <string, string> ExtractContextProperties(IServiceRemotingRequestMessage message) { IServiceRemotingRequestMessageHeader headers = message.GetHeader(); //DANGER!!! this is using reflection to get to internal dictionary of headers collection. if (getHeadersField == null) { getHeadersField = headers.GetType() .GetFields(BindingFlags.NonPublic | BindingFlags.Instance) .First(f => f.Name == "headers"); } var headersCollection = getHeadersField.GetValue(headers) as Dictionary <string, byte[]>; if (headersCollection == null) { return(null); } return(headersCollection.ToDictionary( e => e.Key, e => e.Value == null ? null : Enc.GetString(e.Value))); }