Ejemplo n.º 1
0
 /// <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);
     }
 }
Ejemplo n.º 2
0
        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;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 /// <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);
     }
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
 public static bool HasTags(this IHasTags hasTags)
 {
     return(hasTags.Tags.Any());
 }
Ejemplo n.º 7
0
 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();
 }