Exemplo n.º 1
0
 /// <inheritdoc />
 public override IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
 {
     return(new OrderedKeyValuePairs <string, object>
     {
         { "ppprop", SelectedProperties == null ? null : MediaWikiHelper.JoinValues(SelectedProperties) }
     });
 }
        /// <inheritdoc />
        public override IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
        {
            var p = new OrderedKeyValuePairs <string, object>();

            if (QueryOriginalImage && ThumbnailSize > 0)
            {
                p.Add("piprop", "original|thumbnail|name");
            }
            else if (QueryOriginalImage)
            {
                p.Add("piprop", "original|name");
            }
            else if (ThumbnailSize > 0)
            {
                p.Add("piprop", "thumbnail|name");
            }
            else
            {
                p.Add("piprop", "name");
            }
            if (ThumbnailSize >= 0)
            {
                p.Add("pithumbsize", ThumbnailSize);
            }
            return(p);
        }
Exemplo n.º 3
0
        public void Issue72()
        {
            Assert.Throws <FormatException>(() => MediaWikiVersion.Parse("1.19.5-1+deb7u1"));
            var version = MediaWikiVersion.Parse("1.19.5-1+deb7u1", true);

            Assert.Equal(new MediaWikiVersion(1, 19, 5), version);
        }
Exemplo n.º 4
0
        /// <param name="version"></param>
        /// <inheritdoc />
        public virtual IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
        {
            var propBuilder = new StringBuilder();
            var p           = new OrderedKeyValuePairs <string, object>
            {
                { "action", "query" },
                { "redirects", ResolveRedirects },
                { "maxlag", 5 },
            };

            if (_Properties != null)
            {
                foreach (var prop in _Properties)
                {
                    if (prop.PropertyName != null)
                    {
                        if (propBuilder.Length > 0)
                        {
                            propBuilder.Append('|');
                        }
                        propBuilder.Append(prop.PropertyName);
                    }
                    p.AddRange(prop.EnumParameters(version));
                }
            }
            p.Add("prop", propBuilder.ToString());
            return(p);
        }
Exemplo n.º 5
0
 /// <inheritdoc />
 public override IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
 {
     return(new OrderedKeyValuePairs <string, object>
     {
         { "iiprop", "timestamp|user|comment|url|size|sha1" },
     });
 }
        /// <inheritdoc />
        public override IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
        {
            var p = new OrderedKeyValuePairs <string, object>
            {
                { "lhprop", "pageid|title|redirect" },
                { "lhshow", RedirectFilter.ToString("redirect", "!redirect", null) }
            };

            if (NamespaceSelection != null)
            {
                p.Add("lhnamespace", MediaWikiHelper.JoinValues(NamespaceSelection));
            }
            return(p);
        }
Exemplo n.º 7
0
        /// <inheritdoc />
        public override IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
        {
            var p = new OrderedKeyValuePairs <string, object>
            {
                { "clprop", "sortkey|timestamp|hidden" },
                { "clshow", HiddenCategoryFilter.ToString("hidden", "!hidden", null) }
            };

            if (CategorySelection != null)
            {
                p.Add("clcategories", MediaWikiHelper.JoinValues(CategorySelection));
            }
            return(p);
        }
Exemplo n.º 8
0
        /// <inheritdoc />
        public virtual int GetMaxPaginationSize(MediaWikiVersion version, bool apiHighLimits)
        {
            int limit;

            limit = apiHighLimits ? 500 : 5000;
            if (_Properties != null)
            {
                foreach (var prop in _Properties)
                {
                    limit = Math.Min(limit, prop.GetMaxPaginationSize(version, apiHighLimits));
                }
            }
            return(limit);
        }
Exemplo n.º 9
0
        /// <inheritdoc />
        public override IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
        {
            var properties = new List <string> {
                "timestamp", "user", "comment", "url", "size", "sha1"
            };

            if (QueryExtMetadata)
            {
                properties.Add("extmetadata");
            }

            return(new OrderedKeyValuePairs <string, object>
            {
                { "iiprop", string.Join("|", properties) },
            });
        }
Exemplo n.º 10
0
        public override IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
        {
            // Limit is 500 for user, and 5000 for bots. We take 300 in a batch.
            var p = new OrderedKeyValuePairs <string, object> {
                { "lllimit", 300 }
            };

            if (LanguageLinkProperties != LanguageLinkProperties.None)
            {
                if (version >= new MediaWikiVersion(1, 23))
                {
                    var llprop = "";
                    if ((LanguageLinkProperties & LanguageLinkProperties.Url) == LanguageLinkProperties.Url)
                    {
                        llprop = "url";
                    }
                    if ((LanguageLinkProperties & LanguageLinkProperties.LanguageName) == LanguageLinkProperties.LanguageName)
                    {
                        llprop = llprop.Length == 0 ? "langname" : (llprop + "|langname");
                    }
                    if ((LanguageLinkProperties & LanguageLinkProperties.Autonym) == LanguageLinkProperties.Autonym)
                    {
                        llprop = llprop.Length == 0 ? "autonym" : (llprop + "|autonym");
                    }
                    p.Add("llprop", llprop);
                }
                else if (LanguageLinkProperties == LanguageLinkProperties.Url)
                {
                    p.Add("llurl", true);
                }
                else
                {
                    throw new NotSupportedException("MediaWiki 1.22- only supports LanguageLinkProperties.Url.");
                }
            }
            if (LanguageName != null)
            {
                p.Add("lllang", LanguageName);
            }
            if (LanguageNameLanguage != null)
            {
                p.Add("llinlanguagecode", LanguageNameLanguage);
            }
            return(p);
        }
        /// <inheritdoc />
        public override IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
        {
            var p = new OrderedKeyValuePairs <string, object>
            {
                {
                    "rvprop", FetchContent
                        ? "ids|timestamp|flags|comment|user|userid|contentmodel|sha1|tags|size|content"
                        : "ids|timestamp|flags|comment|user|userid|contentmodel|sha1|tags|size"
                }
            };

            if (Slots != null || version >= new MediaWikiVersion(1, 32))
            {
                // If user specified Slots explicitly, then we will respect it regardless of MW version.
                p.Add("rvslots", Slots == null ? RevisionSlot.MainSlotName : MediaWikiHelper.JoinValues(Slots));
            }
            return(p);
        }
Exemplo n.º 12
0
        /// <inheritdoc />
        public override IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
        {
            var p = new OrderedKeyValuePairs <string, object>
            {
                { "exlimit", "max" },
                { "exintro", IntroductionOnly },
                { "exsectionformat", "plain" },
                { "explaintext", AsPlainText },
            };

            if (MaxCharacters > 0)
            {
                p.Add("exchars", MaxCharacters);
            }
            if (MaxSentences > 0)
            {
                p.Add("exsentences", MaxSentences);
            }
            return(p);
        }
Exemplo n.º 13
0
        /// <inheritdoc />
        public override IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
        {
            var p = new OrderedKeyValuePairs <string, object>
            {
                { "coprop", "globe|dim" },
            };

            if (QueryPrimaryCoordinate && QuerySecondaryCoordinate)
            {
                p.Add("coprimary", "all");
            }
            else if (QueryPrimaryCoordinate)
            {
                p.Add("coprimary", "primary");
            }
            else if (QuerySecondaryCoordinate)
            {
                p.Add("coprimary", "secondary");
            }
            else
            {
                throw new ArgumentException(string.Format(Prompts.ExceptionArgumentExpectEitherBothTrue2, nameof(QueryPrimaryCoordinate), nameof(QuerySecondaryCoordinate)));
            }

            if (!QueryDistanceFromPoint.IsEmpty && QueryDistanceFromPage == null)
            {
                throw new ArgumentException(string.Format(Prompts.ExceptionArgumentExpectEitherDefault2, nameof(QueryDistanceFromPoint), nameof(QueryDistanceFromPage)));
            }
            if (!QueryDistanceFromPoint.IsEmpty)
            {
                p.Add("codistancefrompoint", QueryDistanceFromPoint.Latitude + "|" + QueryDistanceFromPoint.Longitude);
            }
            if (QueryDistanceFromPage != null)
            {
                p.Add("codistancefrompage", QueryDistanceFromPage);
            }

            return(p);
        }
Exemplo n.º 14
0
 /// <inheritdoc />
 public override int GetMaxPaginationSize(MediaWikiVersion version, bool apiHighLimits)
 {
     return(apiHighLimits ? 20 : 10);
 }
Exemplo n.º 15
0
 /// <inheritdoc />
 public int GetMaxPaginationSize(MediaWikiVersion version, bool apiHighLimits)
 {
     return(underlyingProvider.GetMaxPaginationSize(version, apiHighLimits));
 }
Exemplo n.º 16
0
 /// <param name="version"></param>
 /// <inheritdoc />
 public IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
 {
     return(underlyingProvider.EnumParameters(version));
 }
 /// <inheritdoc />
 public override IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
 {
     return(Enumerable.Empty <KeyValuePair <string, object> >());
 }
Exemplo n.º 18
0
 /// <inheritdoc />
 public abstract IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version);
Exemplo n.º 19
0
 /// <inheritdoc />
 public virtual int GetMaxPaginationSize(MediaWikiVersion version, bool apiHighLimits)
 {
     return(apiHighLimits ? 500 : 50);
 }
 /// <inheritdoc />
 public override IEnumerable <KeyValuePair <string, object> > EnumParameters(MediaWikiVersion version)
 {
     return(fixedProp);
 }
 /// <inheritdoc />
 public override int GetMaxPaginationSize(MediaWikiVersion version, bool apiHighLimits) => base.GetMaxPaginationSize(version, apiHighLimits) / 10;