Skip to content

Commit

Permalink
Add defaultNamespaceId argument for Site.OpenSearchAsync.
Browse files Browse the repository at this point in the history
  • Loading branch information
CXuesong committed Nov 13, 2016
1 parent dce7e33 commit 2af0aa3
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions WikiClientLibrary/Site.cs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ public async Task<SiteStatistics> GetStatisticsAsync()
/// <remarks>This overload will allow up to 20 results to be returned, and will not resolve redirects.</remarks>
public Task<IList<OpenSearchResultEntry>> OpenSearchAsync(string searchExpression)
{
return OpenSearchAsync(searchExpression, 20, OpenSearchOptions.None);
return OpenSearchAsync(searchExpression, 20, 0, OpenSearchOptions.None);
}


Expand All @@ -675,7 +675,7 @@ public Task<IList<OpenSearchResultEntry>> OpenSearchAsync(string searchExpressio
/// <remarks>This overload will allow up to 20 results to be returned.</remarks>
public Task<IList<OpenSearchResultEntry>> OpenSearchAsync(string searchExpression, OpenSearchOptions options)
{
return OpenSearchAsync(searchExpression, 20, options);
return OpenSearchAsync(searchExpression, 20, 0, options);
}

/// <summary>
Expand All @@ -689,7 +689,7 @@ public Task<IList<OpenSearchResultEntry>> OpenSearchAsync(string searchExpressio
/// <remarks>This overload will not resolve redirects.</remarks>
public Task<IList<OpenSearchResultEntry>> OpenSearchAsync(string searchExpression, int maxCount)
{
return OpenSearchAsync(searchExpression, maxCount, OpenSearchOptions.None);
return OpenSearchAsync(searchExpression, maxCount, 0, OpenSearchOptions.None);
}

/// <summary>
Expand All @@ -700,8 +700,22 @@ public Task<IList<OpenSearchResultEntry>> OpenSearchAsync(string searchExpressio
/// <param name="maxCount">Maximum number of results to return. No more than 500 (5000 for bots) allowed.</param>
/// <param name="options">Other options.</param>
/// <returns>Search result.</returns>
public async Task<IList<OpenSearchResultEntry>> OpenSearchAsync(string searchExpression,
int maxCount, OpenSearchOptions options)
public Task<IList<OpenSearchResultEntry>> OpenSearchAsync(string searchExpression, int maxCount, OpenSearchOptions options)
{
return OpenSearchAsync(searchExpression, maxCount, 0, options);
}

/// <summary>
/// Performs an opensearch and get results, often used for search box suggestions.
/// (MediaWiki 1.25 or OpenSearch extension)
/// </summary>
/// <param name="searchExpression">The beginning part of the title to be searched.</param>
/// <param name="maxCount">Maximum number of results to return. No more than 500 (5000 for bots) allowed.</param>
/// <param name="defaultNamespaceId">Default namespace id to search. See <see cref="BuiltInNamespaces"/> for a list of possible namespace ids.</param>
/// <param name="options">Other options.</param>
/// <returns>Search result.</returns>
public async Task<IList<OpenSearchResultEntry>> OpenSearchAsync(string searchExpression, int maxCount,
int defaultNamespaceId, OpenSearchOptions options)
{
/*
[
Expand All @@ -725,6 +739,7 @@ public async Task<IList<OpenSearchResultEntry>> OpenSearchAsync(string searchExp
var jresult = await PostValuesAsync(new
{
action = "opensearch",
@namespace = defaultNamespaceId,
search = searchExpression,
limit = maxCount,
redirects = (options & OpenSearchOptions.ResolveRedirects) == OpenSearchOptions.ResolveRedirects,
Expand Down

0 comments on commit 2af0aa3

Please sign in to comment.