コード例 #1
0
        private void GetProperTitles(List <MultilingualPage> mlpl, string code, string project, string[] titles)
        {
            var pages = WikiApiFunctions.GetProperTitles(code, project, titles);

            foreach (var title in titles)
            {
                var page = pages.FirstOrDefault(p => p.Title == title);
                if (page == null)
                {
                    page = WikiApiFunctions.GetProperTitle(code, project, title);
                }
                foreach (var mlp in mlpl)
                {
                    var interwiki = mlp.Interwikis.FirstOrDefault(iw => iw.Code == code && iw.Title == title);
                    if (interwiki == null)
                    {
                        continue;
                    }
                    interwiki.Info       = page;
                    interwiki.IsExcluded = page.IsMissing;
                    interwiki.IsChecked  = true;
                    if (page.RedirectTo.Length <= 0 && page.NormalizedTitle.Length <= 0)
                    {
                        continue;
                    }

                    interwiki.IsRedirect = true;
                    var redirectedIw = new InterwikiItem {
                        Code = code
                    };
                    if (page.RedirectTo.Length > 0)
                    {
                        interwiki.RedirectTo = page.RedirectTo;
                        if (page.RedirectionSection.Length > 0)
                        {
                            interwiki.RedirectTo += "#" + page.RedirectionSection;
                        }
                        redirectedIw.Title = page.RedirectTo;
                    }
                    else
                    {
                        interwiki.RedirectTo = page.NormalizedTitle;
                        redirectedIw.Title   = page.NormalizedTitle;
                    }

                    if (mlp.Interwikis.Any(iw => iw.Code == code && iw.Title == redirectedIw.Title))
                    {
                        continue;
                    }

                    var redirectedPage = pages.FirstOrDefault(p => p.Title == redirectedIw.Title);
                    if (redirectedPage == null)
                    {
                        redirectedIw.IsExcluded = true;
                    }
                    else
                    {
                        redirectedIw.Info       = redirectedPage;
                        redirectedIw.IsExcluded = redirectedPage.IsMissing;
                    }
                    redirectedIw.IsRedirect = false;
                    redirectedIw.IsChecked  = true;


                    mlp.Interwikis.Add(redirectedIw);
                }
            }
        }
コード例 #2
0
        private void GetProperTitles(List<MultilingualPage> mlpl, string code, string project, string[] titles)
        {
            var pages = WikiApiFunctions.GetProperTitles(code, project, titles);
            foreach (var title in titles)
            {
                var page = pages.FirstOrDefault(p => p.Title == title);
                if (page == null)
                    page = WikiApiFunctions.GetProperTitle(code, project, title);
                foreach (var mlp in mlpl)
                {
                    var interwiki = mlp.Interwikis.FirstOrDefault(iw => iw.Code == code && iw.Title == title);
                    if (interwiki == null)
                        continue;
                    interwiki.Info = page;
                    interwiki.IsExcluded = page.IsMissing;
                    interwiki.IsChecked = true;
                    if (page.RedirectTo.Length <= 0 && page.NormalizedTitle.Length <= 0)
                        continue;

                    interwiki.IsRedirect = true;
                    var redirectedIw = new InterwikiItem { Code = code };
                    if (page.RedirectTo.Length > 0)
                    {
                        interwiki.RedirectTo = page.RedirectTo;
                        if (page.RedirectionSection.Length > 0)
                            interwiki.RedirectTo += "#" + page.RedirectionSection;
                        redirectedIw.Title = page.RedirectTo;
                    }
                    else
                    {
                        interwiki.RedirectTo = page.NormalizedTitle;
                        redirectedIw.Title = page.NormalizedTitle;
                    }

                    if (mlp.Interwikis.Any(iw => iw.Code == code && iw.Title == redirectedIw.Title))
                        continue;

                    var redirectedPage = pages.FirstOrDefault(p => p.Title == redirectedIw.Title);
                    if (redirectedPage == null)
                    {
                        redirectedIw.IsExcluded = true;
                    }
                    else
                    {
                        redirectedIw.Info = redirectedPage;
                        redirectedIw.IsExcluded = redirectedPage.IsMissing;
                    }
                    redirectedIw.IsRedirect = false;
                    redirectedIw.IsChecked = true;

                    mlp.Interwikis.Add(redirectedIw);
                }
            }
        }