当前位置: 首页>>代码示例>>C#>>正文


C# DotNetWikiBot.Page类代码示例

本文整理汇总了C#中DotNetWikiBot.Page的典型用法代码示例。如果您正苦于以下问题:C# Page类的具体用法?C# Page怎么用?C# Page使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Page类属于DotNetWikiBot命名空间,在下文中一共展示了Page类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Template

 internal Template(Page p, string s)
 {
     Page = p;
     Text = s;
     Parameters = p.site.ParseTemplate(s);
     Title = Page.site.RemoveNSPrefix(Regex.Match(s, @"^(.+?)($|\|)", RegexOptions.Multiline).Groups[1].Value.Trim(), 10);
 }
开发者ID:darthmaim,项目名称:DotNetWikiBot-Extensions,代码行数:7,代码来源:TemplateExtensions.cs

示例2: ConvertPage

        public static void ConvertPage(string pageName, string newName, bool overwrite = false)
        {
            var db = new ZkDataContext();
            ForumThread thread = db.ForumThreads.FirstOrDefault(x=> x.WikiKey == pageName);
            if (thread == null)
            {
                Console.WriteLine("No ZK wiki page with name {0} found", pageName);
                return;
            }

            string text = thread.ForumPosts.First().Text;
            text = BBCodeToMediaWiki(text);

            Page page = new Page(newWiki, newName);
            page.Load();

            bool update = false;
            if (!page.IsEmpty())
            {
                if (!overwrite)
                {
                    Console.WriteLine("Page already exists, exiting");
                    return;
                }
                else update = true;
            }
            if (newName.StartsWith("Mission Editor", true, System.Globalization.CultureInfo.CurrentCulture))
                page.AddToCategory("Mission Editor");
            page.Save(text, update ? "" : "Ported from ZK wiki by DotNetWikiBot", update);
        }
开发者ID:DeinFreund,项目名称:Zero-K-Infrastructure,代码行数:30,代码来源:WikiPortingMW.cs

示例3: ProcessPage

        protected override void ProcessPage(Page p, EditStatus edit)
        {
            if (p.GetNamespace() != 0) return;
            p.Load();

            var changes = new List<string>();

            p.InsertPlaceholders(GeneralExtensions.Placeholder.Default);

            foreach (var replacement in Replacements.Where(replacement => p.text.Contains(replacement.Key)))
            {
                p.text = p.text.Replace(replacement.Key, replacement.Value);
                changes.Add(replacement.Key + " → " + replacement.Value);
            }
            foreach (var replacement in RegexReplacements)
            {
                var pattern = replacement.Key;
                var replace = replacement.Value;

                pattern.Replace(p.text, match =>
                    {
                        var replaceWith = RegexParseReplaceWithString(match, replace);
                        changes.Add(match.Value + " → " + replaceWith);
                        return replaceWith;
                    });
            }

            p.RemovePlaceholders();

            if (changes.Count > 0)
            {
                edit.Save = true;
                edit.EditComment = "Ersetzt: " + string.Join(", ", changes);
            }
        }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:35,代码来源:ReplacementJob.cs

示例4: ProcessPage

        protected override void ProcessPage(Page p, EditStatus edit)
        {
            if (p.GetNamespace() != 0) return;
            p.Load();

            var before = p.text;

            var changes = new List<string>();

            Match m;
            while ((m = MuenzenRegex.Match(p.text)).Success)
            {
                var kupfer = 0;
                var silber = 0;
                var gold = 0;

                int.TryParse(m.Groups["kupfer"].Value, out kupfer);
                int.TryParse(m.Groups["silber"].Value, out silber);
                int.TryParse(m.Groups["gold"].Value, out gold);

                var muenzen = kupfer + 100*silber + 10000*gold;

                p.text = p.text.Replace(m.Value.Trim(), "{{Münzen|" + muenzen + "}}");

                changes.Add(string.Format("{0}g {1}s {2}k → {3}", gold, silber, kupfer, muenzen));
            }

            if (changes.Count > 0)
            {
                edit.EditComment = string.Format("Münzen ({0}x): {1}", changes.Count, string.Join(", ", changes));
                edit.Save = true;
            }
        }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:33,代码来源:MuenzenJob.cs

示例5: Section

        public Section(string content, Page page, int level)
        {
            _originalContent = content;
            Content = content;
            Page = page;
            Level = level;

            Subsections = SectionExtensions.GetAllSections(Content, page, level + 1);
        }
开发者ID:darthmaim,项目名称:DotNetWikiBot-Extensions,代码行数:9,代码来源:SectionExtensions.cs

示例6: exec

 public static void exec()
 {
     string[] line = System.IO.File.ReadAllLines("list");
     List<string> ignorelist = new List<string>();
     if (System.IO.File.Exists("resultsig"))
     {
         ignorelist.AddRange (System.IO.File.ReadAllLines("resultsig"));
     }
     if (System.IO.File.Exists("results"))
     {
         ignorelist.AddRange (System.IO.File.ReadAllLines("results"));
     }
     int processed = 1;
     foreach (string c in line)
     {
         if (ignorelist.Contains(c))
         {
             continue;
         }
         try
         {
             Page afc = new Page(MainClass.en, "Wikipedia talk:" + c);
             afc.Load();
             if ( afc.text == null ||
                 afc.text.Contains("REDIRECT") ||
                 afc.text.Contains("{{AFC") ||
                 afc.text.Contains("{{WPAFC") ||
                               afc.text == "" ||
                 afc.text.Contains("[[Category:AfC_submissions_with_missing_AfC_template]]")
                              )
             {
                 MainClass.DebugLog("OK:" + c);
                 System.IO.File.AppendAllText("resultsig", c + "\n");
             }
             else
             {
                 MainClass.DebugLog("Category missing:"  + c);
                 afc.text = afc.text + "\n[[Category:AfC_submissions_with_missing_AfC_template]]";
                 afc.Save(afc.text, "Bot: inserting [[Category:AfC_submissions_with_missing_AfC_template]]", false);
                 processed++;
                 System.IO.File.AppendAllText("results", c + "\n");
                 if (processed > 100)
                 {
                     MainClass.DebugLog("Finished for today");
                     return;
                 }
             }
         }
         catch (Exception fail)
         {
             Console.WriteLine(fail.ToString());
             System.IO.File.AppendAllText("errors", c + Environment.NewLine);
         }
     }
     MainClass.Log("end");
 }
开发者ID:WPAFC,项目名称:wikibots,代码行数:56,代码来源:Task1.cs

示例7: CheckIfReviewUnnecessary

        private static bool CheckIfReviewUnnecessary(Page page)
        {
            string newPageText;
            bool unnecessary = false;
            string unnecessaryReason = "";

            if (page.text.ToLower().Contains("{{picasareviewunnecessary}}"))
            {
                // Already marked unnecessary, assume it is
                return true;
            }

            if (IsFlickrReviewed(page))
            {
                unnecessary = true;
                unnecessaryReason = "Also on Flickr and already Flickr reviewed";
            }
            if (HasOtrsTag(page))
            {
                unnecessary = true;
                unnecessaryReason = "Has OTRS tag";
            }
            foreach (string tag in new string[] { "{{pd-usgov", "{{pd-art}}", "{{pd-art|", "{{pd-scan}}", "{{pd-scan|", "{{pd-old", "{{pd-us}}", "{{anonymous-eu}}" })
            {
                if (page.text.ToLower().Contains(tag))
                {
                    unnecessary = true;
                    unnecessaryReason = "Is public domain";
                }
            }
            if (unnecessary)
            {
                newPageText = tagRegex.Replace(page.text, "{{picasareviewunnecessary}}");
                newPageText = new Regex("\\{\\{User:Picasa Review Bot/reviewed-error\\|[^}]*\\}\\}", RegexOptions.IgnoreCase).
                                  Replace(newPageText, "{{picasareviewunnecessary}}");
                if (page.text != newPageText)
                {
                    page.text = newPageText;
                    SavePage(page, "Marked {{picasareviewunnecessary}}: " + unnecessaryReason);
                }
                return true;
            }
            return false;
        }
开发者ID:wikigit,项目名称:Picasa-Review-Bot,代码行数:44,代码来源:Program.cs

示例8: ProcessPage

        protected override void ProcessPage(Page p, EditStatus edit)
        {
            if (p.GetNamespace() != 0) return;

            p.Load();

            var templates = p.GetAllTemplates().Where(t => t.Title.ToLower() == "infobox gegenstand");

            foreach (var template in templates)
            {
                if (template.Parameters.ContainsKey("beschreibung") && _regex.IsMatch(template.Parameters["beschreibung"]))
                {
                    template.Parameters["beschreibung"] = _regex.Replace(template.Parameters["beschreibung"], "[[$1]]");
                    template.Save();
                    edit.Save = true;
                    edit.EditComment = "Attribute in Gegenstandsbeschreibung verlinkt";
                }
            }
        }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:19,代码来源:LinkAttributeInItemDescriptionJob.cs

示例9: ProcessPage

        protected override void ProcessPage(Page p, Job.EditStatus edit)
        {
            if(p.GetNamespace() != 0) return;

            p.Load();

            foreach (var template in p.GetAllTemplates().Where(
                template => (template.Title.Equals("Ausrüstungswerte", StringComparison.OrdinalIgnoreCase)
                             || template.Title.Equals("Rezept", StringComparison.OrdinalIgnoreCase)) &&
                            (template.Parameters.HasValueIgnoreCase("seltenheit", "Aufgestiegen") &&
                             !template.Parameters.ContainsKey("aufwertung"))))
            {
                template.InsertParameterAfter("aufwertung", "nein", "infusion2", "infusion");

                template.Save();

                edit.EditComment = "'aufwertung = nein' hinzugefügt";
                edit.Save = true;
            }
        }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:20,代码来源:AufgestiegenerSchmuckJob.cs

示例10: ProcessPage

        protected override void ProcessPage(Page p, EditStatus edit)
        {
            if (p.GetNamespace() != 0)
                return;
            p.Load();

            //Nur Seiten mit Vorlage:Infobox NSC
            if (p.GetAllTemplates().All(t => t.Title.ToLower() != "infobox nsc")) return;

            //Nur Seiten, die eine Unterseite mit Angeboten haben...
            var m = Regex.Match(p.text, "\\{\\{:" + p.title + "/([^}]+)}}");
            if (!m.Success) return;

            var subpageTitle = m.Groups[1].Value;

            var subpage = new Page(p.site, p.title + "/" + subpageTitle);
            subpage.Load();
            if (!subpage.Exists())
            {
                p.text = p.text.Replace(m.Value, "");
                edit.EditComment = "Verweis auf nicht vorhandene Angebots-Unterseite „" + subpage.title + "“ entfernt";
                edit.Save = true;
            }
            else
            {
                var pl2 = new PageList(p.site);
                pl2.FillFromLinksToPage(subpage.title);
                if (pl2.Count() > 1) return;

                var subpageContent = Regex.Replace(subpage.text, "<noinclude>.*?</noinclude>", "").Trim();

                p.text = p.text.Replace(m.Value, subpageContent);

                subpage.text = "{{Löschantrag|[Bot] In den Hauptartikel „[[" + p.title + "]]“ verschoben}}\n" +
                               subpage.text;
                subpage.Save("[Bot] In Hauptartikel „[[" + p.title + "]]“ verschoben", true);

                edit.EditComment = "Angebot von „" + subpage.title + "“ in den Hauptartikel verschoben";
                edit.Save = true;
            }
        }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:41,代码来源:AngebotSubpageToMainarticleJob.cs

示例11: exec

 public static void exec()
 {
     string[] line = System.IO.File.ReadAllLines("list");
     List<string> ignorelist = new List<string>();
     if (System.IO.File.Exists("resultsig"))
     {
         ignorelist.AddRange (System.IO.File.ReadAllLines("resultsig"));
     }
     if (System.IO.File.Exists("results"))
     {
         ignorelist.AddRange (System.IO.File.ReadAllLines("results"));
     }
     foreach (string c in line)
     {
         if (ignorelist.Contains(c))
         {
             continue;
         }
         try
         {
             Page afc = new Page(MainClass.en, "Wikipedia talk:" + c);
             afc.Load();
             if (afc.text.Contains("REDIRECT") || afc.text.Contains("{{AFC"))
             {
                 MainClass.DebugLog("OK:" + c);
                 System.IO.File.AppendAllText("resultsig", c + "\n");
             }
             else
             {
                 MainClass.DebugLog("Template missing:"  + c);
                 System.IO.File.AppendAllText("results", c + "\n");
             }
         }
         catch (Exception fail)
         {
             Console.WriteLine(fail.ToString());
             System.IO.File.AppendAllText("errors", c + "." + Environment.NewLine);
         }
     }
     MainClass.Log("end");
 }
开发者ID:WPAFC,项目名称:wikibots,代码行数:41,代码来源:Task4.cs

示例12: ProcessPage

        protected override void ProcessPage(Page p, EditStatus edit)
        {
            if (p.GetNamespace() != 0)
                return;

            p.Load();

            var before = p.text;

            foreach (var template in p.GetAllTemplates())
            {
                if (template.Title == "#dpl:" && template.Parameters.ContainsKey("category") &&
                    template.Parameters.ContainsKey("linksto") && template.Parameters.ContainsKey("format"))
                {
                    var linksTo = template.Parameters["linksto"];
                    linksTo = linksTo == p.title ? "{{PAGENAME}}" : linksTo;

                    if (template.Parameters["category"].ToLower() == "trophäe")
                        p.text = p.text.Replace(template.Text, "Beschaffung|gegenstand=" + linksTo + "|kategorie=Trophäe");
                    else if (template.Parameters["category"].ToLower() == "behälter")
                        p.text = p.text.Replace(template.Text, "Beschaffung|gegenstand=" + linksTo + "|kategorie=Behälter");
                }
            }

            if (p.text.Contains("#dpl:") && p.text.Contains("Behälter"))
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("{0} still contains dpl", p.title);
                Console.ResetColor();
            }

            if (p.text != before)
            {
                edit.Save = true;
                edit.EditComment = "DPL durch {{Beschaffung}} ersetzt";
            }
        }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:37,代码来源:BeschaffungTemplateJob.cs

示例13: ProcessPage

        protected override void ProcessPage(Page p, EditStatus edit)
        {
            if (p.GetNamespace() != 0) return;
            p.Load();

            var allChanges = new List<string>();
            var before = p.text;

            foreach (var template in p.GetAllTemplates())
            {
                var templateChanges = new List<string>();
                if (Replacements.ContainsKey(template.Title))
                {
                    foreach (var parameter in template.Parameters)
                    {
                        if (Replacements[template.Title].ContainsKey(parameter.Key))
                        {
                            template.ChangeParametername(parameter.Key, Replacements[template.Title][parameter.Key]);
                            templateChanges.Add(parameter.Key + " → " + Replacements[template.Title][parameter.Key]);
                        }
                    }
                }

                if (templateChanges.Count > 0)
                {
                    template.Save();
                    allChanges.Add(template.Title + ": " + string.Join(", ", templateChanges));
                }
            }

            if (allChanges.Count > 0)
            {
                edit.Save = true;
                edit.EditComment = "Parameter umbenannt: " + string.Join("; ", allChanges);
            }
        }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:36,代码来源:RenameTemplateParameterJob.cs

示例14: LoadEx

 /// <summary>Loads text and metadata for pages in PageList via XML export interface.
 /// Non-existent pages will be automatically removed from the PageList.
 /// Please, don't use this function when going to edit big amounts of pages on
 /// popular public wikis, as it compromises edit conflict detection. In that case,
 /// each page's text should be loaded individually right before its processing
 /// and saving.</summary>
 public void LoadEx()
 {
     if (IsEmpty())
         throw new WikiBotException(Bot.Msg("The PageList is empty. Nothing to load."));
     Bot.LogEvent(Bot.Msg("Loading {0} pages..."), pages.Count);
     string res = site.site + site.indexPath +
         "index.php?title=Special:Export&action=submit";
     string postData = "curonly=True&pages=";
     foreach (Page page in pages)
         postData += HttpUtility.UrlEncode(page.title) + "\r\n";
     XmlReader reader = XmlReader.Create(
         new StringReader(site.PostDataAndGetResultHTM(res, postData)));
     Clear();
     while (reader.ReadToFollowing("page")) {
         Page p = new Page(site, "");
         p.ParsePageXML(reader.ReadOuterXml());
         pages.Add(p);
     }
     reader.Close();
 }
开发者ID:wikigit,项目名称:Picasa-Review-Bot,代码行数:26,代码来源:DotNetWikiBot.cs

示例15: Insert

 /// <summary>Inserts an element into this PageList at the specified index.</summary>
 /// <param name="page">Page object to insert.</param>
 /// <param name="index">Zero-based index.</param>
 public void Insert(Page page, int index)
 {
     pages.Insert(index, page);
 }
开发者ID:wikigit,项目名称:Picasa-Review-Bot,代码行数:7,代码来源:DotNetWikiBot.cs


注:本文中的DotNetWikiBot.Page类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。