コード例 #1
0
        private IAnagramResolver FindBestResolver(AnagramOptions optins)
        {
            IAnagramResolver resolver = null;

            lock (_resolverGate)
            {
                var languageMatchSortedByType = _otherResolvers.FirstOrDefault(r => r.Language == optins.Language && r.Type != AnagramResolverType.File);
                resolver = languageMatchSortedByType;
            }
            return(resolver);
        }
コード例 #2
0
        /// <summary>
        /// Get anagrams using 'advanced' resolvers
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public Task <IEnumerable <string> > GetAnagramsAsync(AnagramOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            //find an advanced resolver
            var resolver = FindBestResolver(options);

            if (resolver == null)
            {
                throw new ArgumentException("Langauge is not supported");
            }
            return(resolver.GetAnagramsAsync(options));
        }