コード例 #1
0
        private static bool TryTake(StringKeeper stringKeeper, Dictionary <string, ApplyIfToken> tokens, out StringKeeper newStringKeeper, out ApplyIfToken token)
        {
            var thisToken = tokens.FirstOrDefault(x => stringKeeper.IsNext(x.Key, false));

            if (thisToken.Key != null)
            {
                var work = stringKeeper.Take(thisToken.Key.Length);
                newStringKeeper = work;
                token           = thisToken.Value;
                return(true);
            }

            newStringKeeper = stringKeeper;
            token           = null;
            return(false);
        }