private static ITagContext ToTagContext(ITagContext tags) { if (tags is TagContext) { return(tags); } else { var builder = new TagContextBuilder(); foreach (var tag in tags) { if (tag != null) { builder.Put(tag.Key, tag.Value); } } return(builder.Build()); } }
private static ITagContextBuilder ToTagContextBuilder(ITagContext tags) { // Copy the tags more efficiently in the expected case, when the TagContext is a TagContextImpl. if (tags is TagContext) { return(new TagContextBuilder(((TagContext)tags).Tags)); } else { var builder = new TagContextBuilder(); foreach (var tag in tags) { if (tag != null) { builder.Put(tag.Key, tag.Value); } } return(builder); } }