Пример #1
0
        public virtual string Format(string format)
        {
            if (Taxon == Taxon.Empty)
            {
                return(string.Empty);
            }

            return(StringFormatting.Tokenize(format, token =>
            {
                if (Taxon.IsMyToken(token))
                {
                    return Taxon.FormatByToken(token);
                }
                else if (IsCodeToken(token))
                {
                    return Code;
                }
                else if (IsRefToken(token))
                {
                    return Reference();
                }
                else if (IsFieldToken(token))
                {
                    return Field();
                }
                else if (IsLocalityToken(token))
                {
                    return Locality;
                }
                throw new Exception("Invalid token");
            }));
        }
        private void AssertFormat(string expected, string format)
        {
            var result = StringFormatting.Tokenize(format, token =>
            {
                if (token == "a")
                {
                    return("1");
                }
                else if (token == "b")
                {
                    return("2");
                }
                return(string.Empty);
            });

            Assert.AreEqual(expected, result);
        }
Пример #3
0
 public virtual string Format(string format)
 {
     return(StringFormatting.Tokenize(format, token => FormatByToken(token)));
 }