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());
        }
Example #2
0
        public string AffixListingText()
        {
            var primaries = new List <string>(Lexicon.Affixes
                                              .Where(aff => aff.IsPrimary == true)
                                              .Select(aff => $"*[{aff.Flag}] [{aff.Type.ToFlag()}] [{aff.Rules.Count(),5}]: {aff.Label}"));

            primaries.Sort((a1, a2) => string.CompareOrdinal(a1, a2));

            var dependents = new List <string>(Lexicon.Affixes
                                               .Where(aff => aff.IsPrimary == false)
                                               .Select(aff => $" [{aff.Flag}] [{aff.Type.ToFlag()}] [{aff.Rules.Count(),5}]: {aff.Label}"));

            dependents.Sort((a1, a2) => string.CompareOrdinal(a1, a2));

            var sb = new StringBuilder();

            sb.AddCommentBlock($"AFFIX LISTING - COUNT: {Lexicon.Affixes.Count} [Primary: {primaries.Count}; Dependents: {dependents.Count}]");
            sb.AddComments(primaries);
            sb.AddComments(dependents);

            return(sb.ToString());
        }
Example #3
0
        private string FileMetaInfoText(bool addComments)
        {
            var sb = new StringBuilder();

            var info = Lexicon.MetaInfo;

            var local = info.Creation.ToLocalTime();
            var utc   = info.Creation.ToUniversalTime();

            sb.AddComments(new string[] {
                $"NAME:      {info.Name}",
                $"LANGUAGE:  {info.LanguageName}",
                $"CREATION:  {local.ToString("R")} [LOC: {local.ToString("O")}; UTC: {utc.ToString("O")}]",
                $"CREATOR:   {info.Creator}",
            });

            sb.AddComments($"CONTRIBUTORS:");
            foreach (var contributor in info.Contributors)
            {
                sb.AddComments($" * {contributor}");
            }
            sb.AppendLine(string.Empty);

            sb.AddSectionBlock("SHORT DESCRIPTION");
            sb.AddComments(info.ShortDescription.Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
            sb.AppendLine(string.Empty);

            sb.AddSectionBlock("LONG DESCRIPTION");
            sb.AddComments(info.LongDescription.Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
            sb.AppendLine(string.Empty);

            sb.AddSectionBlock("README");
            sb.AddComments(info.ReadMe.Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
            sb.AppendLine(string.Empty);

            if (addComments)
            {
                sb.AppendLine(AffixListingText());
            }

            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();
 }