protected void GetRules(string prefixText) { Dawg <string> Dawg; var PrefixText = DictionaryHelper.RemoveStressMarks(prefixText).ToLowerInvariant().Reverse(); var fileBasedDictionary = new FileBasedDictionary(Context.Server); try { using (Stream ReverseDict = fileBasedDictionary.OpenReverseIndex()) { Dawg = Dawg <string> .Load(ReverseDict, Func => { string s = Func.ReadString(); return(s == String.Empty ? null : s); }); } int PrefixLen = Dawg.GetLongestCommonPrefixLength(PrefixText); WriteJSONToResponse(Dawg.MatchPrefix(PrefixText.Take(PrefixLen)) .GroupBy(kvp => kvp.Value, kvp => kvp) .SelectMany(g => g.Take(1)) .Select(kvp => kvp.Value + DictionaryHelper.RuleLineDelimiter + new string(kvp.Key.Reverse().ToArray())) .Take(10) .ToArray()); } catch (Exception e) { WriteJSONToResponse(new [] { "Доступ к словарю в данный момент отсутствует. Возможно происходит построение индексов." }); Email.SendAdminEmail("GetRules", e.ToString()); } }