Exemplo n.º 1
0
 public static NodeRule <MessageInfo, DefaultLinkStyle> GetRule()
 {
     return(new NodeRule <MessageInfo, DefaultLinkStyle>((node, nodeRules, map) =>
     {
         var attr = node.Info.Node.Attributes.FirstOrDefault(x => CompilerUtils.AttributeIs(x, typeof(TTLAttribute)));
         if (attr != null)
         {
             var a = (TTLAttribute)attr;
             var seconds = (double)a._seconds;
             var val = TimeSpan.FromSeconds(seconds);
             if (val.TotalMilliseconds >= 1)
             {
                 var labelText = node.Attributes[GraphvizAttribute.Label.ToString()];
                 labelText = DefaultTheme.CheckAndWrapToHtmlTable(labelText);
                 var newRowText = $"<font color='red' point-size='6'>TTL {val.TotalSeconds:F2} sec</font>";
                 labelText = DefaultTheme.AddNewRow(labelText, newRowText);
                 node.Attributes[GraphvizAttribute.Label.ToString()] = labelText;
             }
         }
     }));
 }
Exemplo n.º 2
0
        public static NodeRule <MessageInfo, DefaultLinkStyle> GetRule()
        {
            return(new NodeRule <MessageInfo, DefaultLinkStyle>((node, nodeRules, map) =>
            {
                var attr = node.Info.Node.Attributes.FirstOrDefault(x => CompilerUtils.AttributeIs(x, typeof(TagsAltAttribute)));
                if (attr != null)
                {
                    var a = (TagsAltAttribute)attr;
                    var tags = a._tags;

                    if (tags.Any())
                    {
                        var labelText = node.Attributes[GraphvizAttribute.Label.ToString()];
                        labelText = DefaultTheme.CheckAndWrapToHtmlTable(labelText);
                        var newRowText = $"<font color='gray' point-size='6'><i>{string.Join(", ", tags.Select(x => "#" + x).ToArray())}</i></font>";
                        labelText = DefaultTheme.AddNewRow(labelText, newRowText);
                        node.Attributes[GraphvizAttribute.Label.ToString()] = labelText;
                    }
                }
            }));
        }