public void AddTag(string name, string value)
 {
     if (_currentActivity == null)
     {
         // Activity is not started yet, add the value to the collection
         // that is going to be passed to StartActivity
         _tagCollection ??= ActivityExtensions.CreateTagsCollection() ?? new List <KeyValuePair <string, object> >();
         _tagCollection?.Add(new KeyValuePair <string, object>(name, value !));
     }
     else
     {
         _currentActivity?.AddTag(name, value !);
     }
 }
            private IList?GetActivitySourceLinkCollection()
            {
                if (_links == null)
                {
                    return(null);
                }

                var linkCollection = ActivityExtensions.CreateLinkCollection();

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

                foreach (var activity in _links)
                {
                    ICollection <KeyValuePair <string, object> >?linkTagsCollection = ActivityExtensions.CreateTagsCollection();
                    if (linkTagsCollection != null)
                    {
                        foreach (var tag in activity.Tags)
                        {
                            linkTagsCollection.Add(new KeyValuePair <string, object>(tag.Key, tag.Value !));
                        }
                    }

                    var link = ActivityExtensions.CreateActivityLink(activity.ParentId !, activity.TraceStateString, linkTagsCollection);
                    if (link != null)
                    {
                        linkCollection.Add(link);
                    }
                }

                return(linkCollection);
            }