Beispiel #1
0
        public void TryGetSuccess(string key, string expected)
        {
            var cache = new StringMap <string>();

            cache.Add("abcde", "1");
            cache.Add("abc", "2");
            cache.Add("abcd", "3");
            cache.Add("bar", "4");
            var success = cache.TryGet(key, out var actual);

            Assert.AreEqual(true, success);
            Assert.AreEqual(expected, actual);
        }
        internal static PaddedFormat GetOrCreate(string?format)
        {
            if (string.IsNullOrEmpty(format))
            {
                return(PaddedFormat.NullFormat);
            }

            if (Cache.TryGet(format, out var match))
            {
                return(match);
            }

            var pos          = 0;
            var paddedFormat = GetOrCreate(format, ref pos);

            if (!WhiteSpaceReader.IsRestWhiteSpace(format, pos))
            {
                paddedFormat = paddedFormat.AsUnknownFormat();
            }

            _ = Cache.Add(format, paddedFormat);
            return(paddedFormat);
        }