예제 #1
0
 static ulif.dictlib GetService(NetworkSetting networkSetting)
 {
     ulif.dictlib service = new ulif.dictlib();
     service.Proxy               = networkSetting.Proxy;
     service.Timeout             = networkSetting.Timeout;
     service.EnableDecompression = true;
     service.Credentials         = CredentialCache.DefaultCredentials;
     service.UserAgent           = "Mozilla/5.0, Translate.Net";
     return(service);
 }
예제 #2
0
        public static string[] GetPhrasesPages(string word, NetworkSetting networkSetting)
        {
            List <string> result = new List <string>();

            ulif.dictlib service = GetService(networkSetting);
            CheckVersion(service);
            bool found;

            bool SearchWordResultSpecified;
            bool rSpecified;
            int  word_idx;

            service.SearchWord(word, gldescdic.PHRAS_DIC,
                               true, true, true, out word_idx, out SearchWordResultSpecified,
                               out found, out rSpecified);

            if (!found)
            {
                return(result.ToArray());
            }

            int word_uid;

            service.ReestrGetID(word_idx, true, gldescdic.PHRAS_DIC, true, true, true, out word_uid, out rSpecified);


            phrasdictphraseology[] phraseologies;
            byte[] first_res = service.phrasPrepare(word_uid, true, out phraseologies);

            List <KeyValuePair <int, sbyte> > used_aid = new List <KeyValuePair <int, sbyte> >();


            for (int i = 0; i < phraseologies.Length; i++)
            {
                KeyValuePair <int, sbyte> kvp = new KeyValuePair <int, sbyte>(phraseologies[i].aid, phraseologies[i].l);
                if (!used_aid.Contains(kvp))
                {
                    result.Add(service.getpharticle2(phraseologies[i].aid, true, phraseologies[i].l, true, "style2_2.css", true, true));
                    used_aid.Add(kvp);
                }
            }

            return(result.ToArray());
        }
예제 #3
0
 static void CheckVersion(ulif.dictlib service)
 {
     lock (lock_obj)
     {
         if (!isVersionChecked)
         {
             string[] res;
             bool     checkverResult;
             bool     checkverResultSpecified;
             service.checkver("1.0.3.28", out checkverResult, out checkverResultSpecified, out res);
             isVersionSupported = checkverResult;
             isVersionChecked   = true;
         }
         if (!isVersionSupported)
         {
             throw new TranslationException("Service version not supported");
         }
     }
 }
예제 #4
0
        public static string GetSynonymsPage(string word, NetworkSetting networkSetting)
        {
            ulif.dictlib service = GetService(networkSetting);
            CheckVersion(service);
            bool found;
            bool SearchWordResultSpecified;
            bool rSpecified;
            int  word_idx;

            service.SearchWord(word, gldescdic.SYN_DIC,
                               true, true, true, out word_idx, out SearchWordResultSpecified,
                               out found, out rSpecified);
            if (!found)
            {
                return("");
            }

            int word_uid;

            service.ReestrGetID(word_idx, true, gldescdic.SYN_DIC, true, true, true, out word_uid, out rSpecified);

            return(service.DictPrepare2(word_uid, true, "", "style2_2.css", gldescdic.SYN_DIC, true, true, true));
        }
예제 #5
0
 static ulif.dictlib GetService(NetworkSetting networkSetting)
 {
     ulif.dictlib service = new ulif.dictlib();
     service.Proxy = networkSetting.Proxy;
     service.Timeout = networkSetting.Timeout;
     service.EnableDecompression = true;
     service.Credentials = CredentialCache.DefaultCredentials;
     service.UserAgent = "Mozilla/5.0, Translate.Net";
     return service;
 }