Example #1
0
        private string AffixesText(bool addComments)
        {
            Lexicon.Affixes.Sort();

            var sb = new StringBuilder();

            sb.AddCommentBlock(new string[] { "AFFIX CLASSES", $"COUNT: {Lexicon.Affixes.Count}" });

            foreach (var affix in Lexicon.Affixes)
            {
                // Add header
                if (addComments)
                {
                    sb.AddCommentBar();
                    sb.AddComments($"[{affix.Flag}] {affix.Label.ToUpperInvariant()}");

                    var comments = affix.Comments?.SplitToLines()?.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim());

                    if (comments.Count() > 0)
                    {
                        sb.AddSectionBar();

                        sb.AddComments(comments);
                    }

                    sb.AddCommentBar();
                }

                // Affix Intro
                sb.AppendLine($"{affix.Type.ToFlag()} {affix.Flag} {(affix.CanCombine ? 'Y' : 'N')} {affix.Rules.Count}");

                // Sort the rules
                affix.Rules.Sort();

                // Rules
                sb.AppendLineCollection(affix.Rules.Select(r => r.ToText(affix, Lexicon, addComments)));

                if (addComments)
                {
                    sb.AppendLine(string.Empty);
                }
            }

            return(sb.ToString());
        }
 /// <summary>
 /// Adds the comment block.
 /// </summary>
 /// <param name="sb">The sb.</param>
 /// <param name="comments">The comments.</param>
 public static void AddCommentBlock(this StringBuilder sb, IEnumerable <string> comments)
 {
     sb.AddCommentBar();
     sb.AddComments(comments);
     sb.AddCommentBar();
 }
 /// <summary>
 /// Adds the comment block.
 /// </summary>
 /// <param name="sb">The sb.</param>
 /// <param name="comments">The comments.</param>
 public static void AddCommentBlock(this StringBuilder sb, string comments)
 {
     sb.AddCommentBar();
     sb.AddComments(comments);
     sb.AddCommentBar();
 }