예제 #1
0
        void work_DoWork(object sender, DoWorkEventArgs e)
        {
            object transLate = new Object();
            Type   type      = null;

            switch (TeanslateApi)
            {
            case "百度Baidu":
                transLate = new BaiduTranslate();
                type      = typeof(BaiduTranslate);
                break;

            case "谷歌Google":
                transLate = new GoogleTranslate();
                type      = typeof(GoogleTranslate);
                break;

            case "腾讯Tencent":
                transLate = new TencentTranslate();
                type      = typeof(TencentTranslate);
                break;

            case "必应Bing":
                translation = (new BingTranslate()).必应Bing(textBox1.Text);
                return;
            }
            string 原文语言 = TDictionary.langDic[TeanslateApi][label2.Text];

            lanTo = TDictionary.langDic[TeanslateApi][label4.Text];
            MethodInfo mt = type.GetMethod(TeanslateApi);

            translation = (string)mt.Invoke(transLate, new object[] { textBox1.Text, 原文语言, lanTo });
        }
예제 #2
0
        private string Translate(string str)
        {
            object transLate = new Object();
            Type   type      = null;

            switch (translateApi)
            {
            case "百度Baidu":
                transLate = new BaiduTranslate();
                type      = typeof(BaiduTranslate);
                break;

            case "腾讯Tencent":
                transLate = new TencentTranslate();
                type      = typeof(TencentTranslate);
                break;
            }
            MethodInfo mt = type.GetMethod(translateApi);

            return((string)mt.Invoke(transLate, new object[] { str, "auto", lanToVaule }));;
        }