/// <summary> /// Set all items as tags. /// </summary> public static void SetTags(this IHasTags hasTags, IEnumerable <KeyValuePair <string, string> > tags) { foreach (var(key, value) in tags) { hasTags.SetTag(key, value); } }
private void FetchFromTagsNode(XmlReader reader, IHasTags item) { reader.MoveToContent(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "Tag": { var tag = reader.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace(tag)) { item.AddTag(tag); } break; } default: reader.Skip(); break; } } } }
/// <summary> /// Applies the default tags to an event without resetting existing tags. /// </summary> /// <param name="options">The options to read the default tags from.</param> /// <param name="hasTags">The event to apply the tags to.</param> public static void ApplyDefaultTags(this SentryOptions options, IHasTags hasTags) { foreach (var defaultTag in options.DefaultTags .Where(t => !hasTags.Tags.TryGetValue(t.Key, out _))) { hasTags.SetTag(defaultTag.Key, defaultTag.Value); } }
public static void AddTag(this IHasTags item, string name) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException("name"); } if (!item.Tags.Contains(name, StringComparer.OrdinalIgnoreCase)) { item.Tags.Add(name); } }
private void FormatTags(IHasTags hasTags, StringBuilder result) { if (!hasTags.Tags.Any()) { return; } bool first = true; foreach (var tag in hasTags.Tags) { if (!first) { result.Append(" "); } first = false; FormatHasLocation(tag, result); result.Append(tag.Name); } result.AppendLine(); }
public static bool HasTags(this IHasTags hasTags) { return(hasTags.Tags.Any()); }
private void FormatTags(IHasTags hasTags, StringBuilder result) { if (!hasTags.Tags.Any()) return; bool first = true; foreach (var tag in hasTags.Tags) { if (!first) result.Append(" "); first = false; FormatHasLocation(tag, result); result.Append(tag.Name); } result.AppendLine(); }