本文整理匯總了C#中WikiFunctions.API.ApiEdit.Open方法的典型用法代碼示例。如果您正苦於以下問題:C# ApiEdit.Open方法的具體用法?C# ApiEdit.Open怎麽用?C# ApiEdit.Open使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WikiFunctions.API.ApiEdit
的用法示例。
在下文中一共展示了ApiEdit.Open方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ProcessArticle
public string ProcessArticle(IAutoWikiBrowser sender, IProcessArticleEventArgs eventargs)
{
if (!Enabled) return eventargs.ArticleText;
if (username == "" || password == "")
{
MessageBox.Show("Source wiki username and/or password not set. Turning off the plugin.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
disablePlugin();
return eventargs.ArticleText;
}
String linkTitle;
String linkBody;
String sourceText = eventargs.ArticleText;
String url = String.Format("http://{0}.wikipedia.org/w/", SourceLanguage);
ApiEdit sourceWiki = new ApiEdit(url);
try
{
sourceWiki.Login(username, password);
}
catch (LoginException e)
{
MessageBox.Show("Source wiki username and/or password incorrect. Turning off the plugin.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
disablePlugin();
return eventargs.ArticleText;
}
#if DEBUG_OUTPUT_DIALOG
DebugOutput dlg = new DebugOutput();
dlg.Show(sender.Form);
#endif
String langCode = Variables.LangCode.ToString();
Regex r = new Regex(String.Format(@"\[\[{0}:([^\]]+)\]\]", langCode));
Match m;
String replaceReg;
String replaceTo;
string[] arr = { eventargs.ArticleTitle };
LinksOnPageListProvider linksProvider = new LinksOnPageListProvider();
List<Article> links = linksProvider.MakeList(arr);
// Message
AWBForm.StartProgressBar();
AWBForm.StatusLabelText = String.Format("Translating {0} links...", links.Count);
#if DEBUG_OUTPUT_DIALOG
dlg.StartSection(string.Format("Article {0}", eventargs.ArticleTitle));
#endif
foreach (Article link in links)
{
#if DEBUG_OUTPUT_DIALOG
dlg.StartSection(string.Format("Link: {0}", link.Name));
#endif
linkTitle = link.Name;
linkBody = sourceWiki.Open(linkTitle);
m = r.Match(linkBody);
if (m.Success)
{
#if DEBUG_OUTPUT_DIALOG
dlg.AddSection("From: ", linkTitle);
dlg.AddSection("To: ", m.Groups[1].ToString());
#endif
replaceReg = String.Format(@"\[\[{0}\]\]", linkTitle);
replaceTo = String.Format("[[{0}|{1}]]", m.Groups[1], linkTitle);
sourceText = Regex.Replace(sourceText, replaceReg, replaceTo, RegexOptions.IgnoreCase);
replaceReg = String.Format(@"\[\[{0}\|([^\]]+)\]\]", linkTitle);
replaceTo = String.Format("[[{0}|$1]]", m.Groups[1], linkTitle);
sourceText = Regex.Replace(sourceText, replaceReg, replaceTo, RegexOptions.IgnoreCase);
}
#if DEBUG_OUTPUT_DIALOG
else {
dlg.AddSection("No match", "");
}
#endif
#if DEBUG_OUTPUT_DIALOG
dlg.EndSection();
#endif
Application.DoEvents();
}
#if DEBUG_OUTPUT_DIALOG
dlg.EndSection();
#endif
AWBForm.StopProgressBar();
AWBForm.StatusLabelText = "";
eventargs.EditSummary = "Automatic translation";
return sourceText;
}