本文整理汇总了C#中PageList类的典型用法代码示例。如果您正苦于以下问题:C# PageList类的具体用法?C# PageList怎么用?C# PageList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PageList类属于命名空间,在下文中一共展示了PageList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestInitialize
public void TestInitialize()
{
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
Formatting = Formatting.None,
Converters = new JsonConverter[] { new JsonKnownTypeConverter() }
};
string jsonPageList = AssemblyResourceReader.ReadAsString("Test_Data.PageList.json");
this.pageList = JsonConvert.DeserializeObject<PageList>(jsonPageList);
}
示例2: Start
protected override void Start()
{
if(Pages.Any()) return;
var pl = new PageList(Site);
pl.FillAllFromCategoryTree("Kategorie:Schmuck");
Pages.AddRange(pl.ToEnumerable());
pl.FillAllFromCategoryTree("Kategorie:Rücken");
Pages.AddRange(pl.ToEnumerable());
}
示例3: GetAllPage
public static PageList GetAllPage()
{
if (s_PageCache == null)
{
lock (s_SyncObj)
{
string path = GetConfigPath();
s_PageCache = XmlHelper.LoadFromXmlCache<PageList>(path);
return s_PageCache;
}
}
else
return s_PageCache;
}
示例4: PageReplacementAlgorithm
/// <summary>
/// Creates a new instance of <see cref="PageReplacementAlgorithm"/>.
/// </summary>
/// <param name="pool">The memory pool that blocks will be allocated from.</param>
public PageReplacementAlgorithm(MemoryPool pool)
{
if (pool.PageSize < 4096)
throw new ArgumentOutOfRangeException("PageSize Must be greater than 4096", "pool");
if (!BitMath.IsPowerOfTwo(pool.PageSize))
throw new ArgumentException("PageSize Must be a power of 2", "pool");
m_maxValidPosition = (int.MaxValue - 1) * (long)pool.PageSize; //Max position
m_syncRoot = new object();
m_memoryPageSizeMask = pool.PageSize - 1;
m_memoryPageSizeShiftBits = BitMath.CountBitsSet((uint)m_memoryPageSizeMask);
m_pageList = new PageList(pool);
m_arrayIndexLocks = new WeakList<PageLock>();
}
示例5: Main
static void Main(string[] args)
{
foreach (var line in File.ReadLines("config.txt"))
{
var indexOfSep = line.IndexOf('=');
var key = line.Substring(0,indexOfSep).Trim();
var val = line.Substring(indexOfSep + 1).Trim();
if (key == "user") User = val;
if (key == "pass") Pass = val;
if (key == "apiAuthentication") ApiAuthentication = val;
}
if (string.IsNullOrEmpty(User) || string.IsNullOrEmpty(Pass) || string.IsNullOrEmpty(ApiAuthentication))
{
Console.WriteLine("Incomplete config");
return;
}
var statusApi = new StatusApi();
statusApi.SetStatus(false);
var s = new Site("http://wiki-de.guildwars2.com/wiki/", User, Pass);
if (args.Contains("-generatePagelist") || !File.Exists("pagelist.txt"))
{
Console.WriteLine("Generating pagelist...");
var pagelist = new PageList(s);
pagelist.FillFromCategoryTree("Guild Wars 2");
pagelist.SaveTitlesToFile("pagelist.txt");
}
try
{
Run(s);
}
finally
{
statusApi.SetStatus(false);
}
}
示例6: GetLinks
/// <summary>Finds all internal wikilinks in page text, excluding interwiki
/// links, links to sister projects, categories, embedded images and links in
/// image descriptions.</summary>
/// <returns>Returns the PageList object, in which page titles are the wikilinks,
/// found in text.</returns>
public PageList GetLinks()
{
MatchCollection matches = Site.wikiLinkRE.Matches(text);
StringCollection exclLinks = new StringCollection();
exclLinks.AddRange(GetInterWikiLinks());
exclLinks.AddRange(GetSisterWikiLinks(true));
string str;
int fragmentPosition;
PageList pl = new PageList(site);
for(int i = 0; i < matches.Count; i++) {
str = matches[i].Groups[1].Value;
if (str.StartsWith(site.namespaces["6"] + ":", true, site.langCulture) ||
str.StartsWith(Site.wikiNSpaces["6"] + ":", true, site.langCulture) ||
str.StartsWith(site.namespaces["14"] + ":", true, site.langCulture) ||
str.StartsWith(Site.wikiNSpaces["14"] + ":", true, site.langCulture))
continue;
str = str.TrimStart(':');
if (exclLinks.Contains(str))
continue;
fragmentPosition = str.IndexOf("#");
if (fragmentPosition != -1)
str = str.Substring(0, fragmentPosition);
pl.Add(new Page(site, str));
}
return pl;
}
示例7: GetMediaWikiMessage
/// <summary>Gets a specified MediaWiki message.</summary>
/// <param name="title">Title of the message.</param>
/// <returns>Returns raw text of the message.
/// If the message doesn't exist, exception is thrown.</returns>
public string GetMediaWikiMessage(string title)
{
if (string.IsNullOrEmpty(title))
throw new ArgumentNullException("title");
title = namespaces["8"].ToString() + ":" + Bot.Capitalize(RemoveNSPrefix(title, 8));
if (messages == null)
messages = new PageList(this);
else if (messages.Contains(title))
return messages[title].text;
string src;
try {
src = GetPageHTM(site + indexPath + "index.php?title=" +
HttpUtility.UrlEncode(title.Replace(" ", "_")) +
"&action=raw&usemsgcache=1&dontcountme=s");
}
catch (WebException e) {
if (e.Message.Contains(": (404) "))
throw new WikiBotException(
string.Format(Bot.Msg("MediaWiki message \"{0}\" was not found."), title));
else
throw;
}
if (string.IsNullOrEmpty(src)) {
throw new WikiBotException(
string.Format(Bot.Msg("MediaWiki message \"{0}\" was not found."), title));
}
messages.Add(new Page(this, title));
messages[messages.Count()-1].text = src;
return src;
}
示例8: CompleteLogin
void CompleteLogin()
{
if (errorMessage != null)
{
MessageBox.Show(errorMessage);
loadingDialog.Hide();
Login();
return;
}
numLoadAheadPages = loginForm.MaxLoadAheadPages;
numCategoryPagesToRetrieve = loginForm.MaxCategoryPages;
randomizePageOrder = loginForm.RandomizeOrder;
loadPageListOnDemand = !randomizePageOrder;
pageList = new PageList(site);
pageListSource = loginForm.PageListSource;
pageListSourceValue = loginForm.PageListSourceValue;
if (loadPageListOnDemand)
{
// Actually just loading some of the list of pages, more will be loaded on-demand later
loadingDialog.Message = "Loading list of pages...";
}
else
{
loadingDialog.Message = "Loading list of pages (up to " + numCategoryPagesToRetrieve + ")...";
}
Thread fillFromCategoryThread = new Thread(new ThreadStart(delegate()
{
switch (pageListSource)
{
case PageListSource.category:
if (loadPageListOnDemand)
{
pageList.FillSomeFromCategoryEx(pageListSourceValue, ref pageListNext);
}
else
{
pageList.FillAllFromCategoryEx(pageListSourceValue, numCategoryPagesToRetrieve);
}
Invoke(new MethodInvoker(CompletePageListLoad));
break;
case PageListSource.file:
pageList.FillFromFile(pageListSourceValue);
Invoke(new MethodInvoker(CompletePageListLoad));
break;
default:
throw new ArgumentOutOfRangeException();
}
//pageList.FillFromFile("pages.txt"); // just for debugging to load up some pages
}));
fillFromCategoryThread.Start();
}
示例9: GetEmpty
/// <summary>
/// ����һ���յķ�ҳ�����
/// </summary>
/// <returns></returns>
public static PageList GetEmpty()
{
PageList p = new PageList();
p.Results = new ArrayList();
p.Current = 1;
p.RecordCount = 0;
return p;
}
示例10: FillSubsFromCategory
/// <summary>Gets subcategories titles for this PageList from specified wiki category page,
/// excluding other pages. Use FillFromCategory function to get other pages.</summary>
/// <param name="categoryName">Category name, with or without prefix.</param>
public void FillSubsFromCategory(string categoryName)
{
int count = pages.Count;
PageList pl = new PageList(site);
pl.FillAllFromCategory(categoryName);
pl.FilterNamespaces(new int[] {14});
pages.AddRange(pl.pages);
if (pages.Count != count)
Bot.LogEvent(Bot.Msg("PageList filled with {0} subcategory page titles, " +
"found in \"{1}\" category."), (pages.Count - count).ToString(), categoryName);
else
Console.Error.WriteLine(
Bot.Msg("Nothing was found in \"{0}\" category."), categoryName);
}
示例11: GetMediaWikiMessagesEx
/// <summary>Gets all MediaWiki messages from "Special:Allmessages" page and dumps
/// them to HTM file.</summary>
/// <param name="forceLoad">If true, the messages are updated unconditionally. Otherwise
/// the messages are updated only if they are outdated.</param>
public void GetMediaWikiMessagesEx(bool forceLoad)
{
if (messages == null)
messages = new PageList(this);
string filePathName = "Cache" + Path.DirectorySeparatorChar +
HttpUtility.UrlEncode(site.Replace("://", ".")) + ".messages.htm";
if (forceLoad == true || !File.Exists(filePathName) ||
(DateTime.Now - File.GetLastWriteTime(filePathName)).Days > 90) {
Bot.LogEvent(Bot.Msg("Updating MediaWiki messages dump. Please, wait..."));
string res = site + indexPath + "index.php?title=Special:Allmessages";
File.WriteAllText(filePathName, GetPageHTM(res), Encoding.UTF8);
Bot.LogEvent(Bot.Msg("MediaWiki messages dump updated successfully."));
}
XmlDocument doc = new XmlDocument();
doc.XmlResolver = null;
string text = File.ReadAllText(filePathName, Encoding.UTF8).Replace(" ", " "); ;
doc.LoadXml(text);
XmlNodeList nl1 = doc.DocumentElement.SelectNodes(
".//ns:table[@id = 'allmessagestable']/ns:tr[@class = 'def' or @class = 'orig']/" +
"ns:td/ns:a/ns:span", xmlNS);
XmlNodeList nl2 = doc.DocumentElement.SelectNodes(
".//ns:table[@id = 'allmessagestable']/ns:tr[@class = 'def' or @class = 'new']/" +
"ns:td[last()]", xmlNS);
if (nl1.Count == 0 || nl1.Count != nl2.Count)
throw new WikiBotException(Bot.Msg("MediaWiki messages parsing failed."));
for (int i = 0; i < nl1.Count; i++) {
messages.Add(new Page(this, HttpUtility.HtmlDecode(nl1[i].InnerXml)));
messages[messages.Count()-1].text = HttpUtility.HtmlDecode(nl2[i].InnerXml.Trim());
}
}
示例12: SingleSectionValid
public void SingleSectionValid()
{
ApplicationData applicationData = new ApplicationData
{
{ "text_field_one", string.Empty },
{ "text_field_three", "even more data" },
{ "text_field_two", string.Empty }
};
Application application = new Application(null, FORM_ID, null, null, applicationData);
PageList pagesToValidate = new PageList { this.product.FormDefinition.Pages.First() };
ValidationResults results = this.ApplicationManager.ValidateApplication(this.sessionData, application, pagesToValidate, this.product.FormDefinition.Pages.AllControls, 2);
Assert.IsTrue(results.IsValid);
}
示例13: Revert
/// <summary>Undoes the last edit, so page text reverts to previous contents.
/// The function doesn't affect other operations like renaming.</summary>
/// <param name="comment">Revert comment.</param>
/// <param name="isMinorEdit">Minor edit mark (pass true for minor edit).</param>
public void Revert(string comment, bool isMinorEdit)
{
if (string.IsNullOrEmpty(title))
throw new WikiBotException(Bot.Msg("No title specified for page to revert."));
PageList pl = new PageList(site);
if (Bot.useBotQuery == true && site.botQuery == true &&
site.botQueryVersions.ContainsKey("ApiQueryRevisions.php"))
pl.FillFromPageHistoryEx(title, 2, false);
else
pl.FillFromPageHistory(title, 2);
if (pl.Count() != 2) {
Console.Error.WriteLine(Bot.Msg("Can't revert page \"{0}\"."), title);
return;
}
pl[1].Load();
Save(pl[1].text, comment, isMinorEdit);
Bot.LogEvent(Bot.Msg("Page \"{0}\" was reverted."), title);
}
示例14: Main
public static int Main()
{
// Se registra en la página y configura el bot
Site welp = iniciar();
leerOpciones(Environment.GetCommandLineArgs());
if (welp == null)
return 1;
// Cuenta del número de ediciones
int cuenta = 0;
// Obtiene todos los trabajos (de momento en el espacio de nombre Principal)
PageList todas = new PageList(welp);
todas.FillFromAllPages("Trabajo:", 0, false, Int32.MaxValue, "Trabajo;");
foreach (Page pag in todas)
{
pag.Load();
// Si ya hay indicación de curso no hace nada
List<string> cats = pag.GetCategories();
if (cats.Exists(patronCCurso.IsMatch))
continue;
// Para averiguar el curso obtiene la fecha de la
// primera edición
PageList hist = new PageList(welp);
hist.FillFromPageHistory(pag.title, Int32.MaxValue);
DateTime fc = hist[hist.Count()-1].timestamp;
// Distingue en base a ella el curso
int año = fc.Year;
// Si es antes del 29 de septiembre (aprox) es que es
// del curso que empieza en el año anterior
if (fc.Month < 9 || fc.Month == 9 && fc.Day < 29)
año--;
string curso = "Curso " + año + "-" + (año + 1);
// Muestra información por consola
Console.Error.WriteLine("«" + pag.title + "» creado en " + fc + " => " + curso);
cuenta++;
if (!simulado) {
pag.AddToCategory(curso);
pag.Save("bot: categorización de trabajos por curso", true);
}
}
// Resumen de las operaciones
Console.Error.WriteLine("El bot " + (simulado ? "hubiera realizado " : "realizó ") + cuenta + " ediciones.");
return 0;
}
示例15: GetMediaWikiMessages
/// <summary>Gets all MediaWiki messages and dumps it to XML file.</summary>
/// <param name="forceLoad">If true, the messages are forced to be updated.</param>
public void GetMediaWikiMessages(bool forceLoad)
{
if (forceLoad == false)
messages = new PageList(this);
string filePathName = "Cache/" + HttpUtility.UrlEncode(site.Replace('/','_').Replace(':','_'))+ ".xml";
if (forceLoad == false && File.Exists(filePathName) &&
(DateTime.Now - File.GetLastWriteTime(filePathName)).Days <= 90) {
messages.FillAndLoadFromXMLDump(filePathName);
return;
}
Console.WriteLine("Updating MediaWiki messages dump. Please, wait...");
PageList pl = new PageList(this);
pl.FillFromAllPages("!", 8, false, 10000);
File.Delete(filePathName);
pl.SaveXMLDumpToFile(filePathName);
Console.WriteLine("MediaWiki messages dump updated successfully.");
messages.FillAndLoadFromXMLDump(filePathName);
}