Ejemplo n.º 1
0
        public string Describe(string name, DescMods mods = DescMods.None, int quantity = 1, string adj = "")
        {
            string art;

            adj = mods.HasFlag(DescMods.NoAdjective) ? string.Empty : adj;
            if (adj.Length > 0)
            {
                adj += " ";
            }

            if (mods.HasFlag(DescMods.Article))
            {
                if (mods.HasFlag(DescMods.Definite))
                {
                    art = "the ";
                }
                else
                {
                    if (quantity == 1)
                    {
                        var  leadingWord  = adj.Length > 0 ? adj : name;
                        bool leadingVowel = HasLeadingVowelSound(leadingWord);
                        art = leadingVowel ? "an " : "a ";
                    }
                    else
                    {
                        art = mods.HasFlag(DescMods.Quantity) ? $"{quantity} " : "some ";
                    }
                }
            }
            else
            {
                art = mods.HasFlag(DescMods.Quantity) ? $"{quantity} " : string.Empty;
            }

            var s           = (quantity == 1) ? string.Empty : "s";
            var description = $"{art}{adj}{name}{s}";

            if (mods.HasFlag(DescMods.LeadingCapital) && !string.IsNullOrEmpty(description))
            {
                description = char.ToUpper(description[0], CultureInfo.InvariantCulture) + description.Substring(1);
            }

            return(description);
        }
Ejemplo n.º 2
0
 public virtual string Describe(IItem item, DescMods mods = DescMods.None)
 {
     return(Describe(item.Name, mods, item.Quantity, item.Adjective));
 }