Пример #1
0
        public IEnumerable <LibraryPuzzle> GetPuzzlesWithCachingUsingRegex(string searchString)
        {
            if (searchString.Contains("~"))
            {
                // Try direct
                LibraryPuzzle p = null;
                try
                {
                    p = GetPuzzleWithCaching(PuzzleIdent.Parse(searchString));
                }
                catch (ArgumentException) { }
                catch (InvalidDataException) { }

                if (p != null)
                {
                    yield return(p);

                    yield break;
                }
            }

            Library lib = null;

            try
            {
                lib = GetLibraryWithCaching(searchString);
            }
            catch (ArgumentException) { }
            catch (InvalidDataException) { }
            catch (FileNotFoundException) { }

            if (lib != null)
            {
                foreach (var ll in lib)
                {
                    yield return(ll);
                }

                yield break;
            }

            // TODO: Regex
        }
Пример #2
0
        public LibraryPuzzle GetPuzzleWithCaching(PuzzleIdent ident)
        {
            var l = GetLibraryWithCaching(ident.Library);

            return(l?.FirstOrDefault(x => x.Ident.Puzzle == ident.Puzzle) ?? throw new ArgumentException($"NotFound: {ident}"));
        }