Exemple #1
0
        private static (ArchNode Node, string Link, string Uri) GetLink(this ArchNode node, List <string> prevs)
        {
            var link = node.ToString();
            var uri  = node.GetUri(prevs);

            return(node, link, uri);
        }
Exemple #2
0
        private static string GetUri(this ArchNode node, List <string> prevs)
        {
            var uri = node.ToString().ToLowerInvariant().Trim().Replace("  ", " ").Replace(" ", "-").Where(IsValid).Map(string.Concat);

            prevs.Add(uri);
            var id = prevs.Count(i => i == uri) - 1;

            return(id == 0 ? uri : $"{uri}-{id}");
        }
Exemple #3
0
 // Helpers/GetDisplayString
 private static string GetDisplayString(this ArchNode node, string link, string uri)
 {
     return(node switch {
         ProjectArchNode
         => link.Link(uri).Item1(),
         ModuleArchNode
         => link.Link(uri).Item2(),
         NamespaceArchNode
         => link.Link(uri).Item3(),
         GroupArchNode
         => link.Link(uri).Item4(),
         { } => throw new ArgumentException("ArchNode is invalid: " + node),
Exemple #4
0
 // Helpers/GetDisplayString
 private static string GetDisplayString(this ArchNode node)
 {
     return(node switch {
         ProjectArchNode
         => "Project:      {0}".Format(node.Name),
         ModuleArchNode
         => "- Module:     {0}".Format(node.Name),
         NamespaceArchNode
         => "-- Namespace: {0}".Format(node.Name),
         GroupArchNode
         => "--- Group:    {0}".Format(node.Name),
         TypeArchNode
         => "--- Type:     {0}".Format(node.Name),
         { } => throw new ArgumentException("ArchNode is invalid: " + node.GetType()),
Exemple #5
0
 // Helpers
 private static bool IsDefaultGroup(this ArchNode node)
 {
     return(node is GroupArchNode group && group.IsDefault);
 }