internal static void DoTranslate(IDictDServiceItem dictServiceItem, string phrase, LanguagePair languagesPair, string subject, Result result, NetworkSetting networkSetting) { ServiceItem si = dictServiceItem as ServiceItem; DictionaryClient dc = null; try { dc = DictDClientsPool.GetPooledClient(dictServiceItem.Urls); DefinitionCollection definitions = dc.GetDefinitions(phrase, si.Name); string translation; if (definitions != null && definitions.Count > 0) { foreach (Definition df in definitions) { translation = "html!<div style='width:{allowed_width}px;overflow:scroll;overflow-y:hidden;overflow-x:auto;'><pre>" + df.Description.Replace("\r\n", "<br />") + " </pre></div>"; result.Translations.Add(translation); } } else { result.ResultNotFound = true; throw new TranslationException("Nothing found"); } } catch (DictionaryServerException e) { if (e.ErrorCode == 552) //No definitions found { result.ResultNotFound = true; throw new TranslationException("Nothing found"); } else { throw; } } finally { if (dc != null) { DictDClientsPool.PushPooledClient(dc); } } }
internal static void DoTranslate(IDictDServiceItem dictServiceItem, string phrase, LanguagePair languagesPair, string subject, Result result, NetworkSetting networkSetting) { ServiceItem si = dictServiceItem as ServiceItem; DictionaryClient dc = null; try { dc = DictDClientsPool.GetPooledClient(dictServiceItem.Urls); DefinitionCollection definitions = dc.GetDefinitions(phrase, si.Name); string translation; if(definitions != null && definitions.Count > 0) { foreach(Definition df in definitions) { translation = "html!<div style='width:{allowed_width}px;overflow:scroll;overflow-y:hidden;overflow-x:auto;'><pre>" + df.Description.Replace("\r\n", "<br />") + " </pre></div>"; result.Translations.Add(translation); } } else { result.ResultNotFound = true; throw new TranslationException("Nothing found"); } } catch(DictionaryServerException e) { if(e.ErrorCode == 552) //No definitions found { result.ResultNotFound = true; throw new TranslationException("Nothing found"); } else throw; } finally { if(dc != null) DictDClientsPool.PushPooledClient(dc); } }