-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge development into Stable for V2.0.0
- Loading branch information
EternalClickbait
authored
Oct 29, 2019
1 parent
882faad
commit 76bf5d9
Showing
15 changed files
with
356 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,3 +328,4 @@ ASALocalRun/ | |
|
||
# MFractors (Xamarin productivity tool) working folder | ||
.mfractor/ | ||
*.cs___jb_tmp___ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Creepysin/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Wikipedia/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Wikipedia_0027s/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace CreepysinStudios.WikiDotNet | ||
{ | ||
/// <summary> | ||
/// A class that represents a Wikipedia API error | ||
/// </summary> | ||
// ReSharper disable once ClassCannotBeInstantiated | ||
public sealed class Error | ||
{ | ||
/// <summary> | ||
/// What error code does this this error correspond to | ||
/// </summary> | ||
[JsonProperty("code")] public readonly string Code; | ||
|
||
/// <summary> | ||
/// Any extra information the assist with debugging | ||
/// </summary> | ||
[JsonProperty("data")] public readonly string Data; | ||
|
||
/// <summary> | ||
/// What Wikipedia module gave this error | ||
/// </summary> | ||
[JsonProperty("module")] public readonly string Module; | ||
|
||
/// <summary> | ||
/// Information about this error | ||
/// </summary> | ||
[JsonProperty("*")] public readonly string Text; | ||
|
||
private Error() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Class Inheritance | ||
|
||
### WikiSearchResponse | ||
* #### Query | ||
* ##### Search Results (Array) | ||
* ###### Ns (Namespace?) | ||
* ###### Last edited | ||
* ###### Page ID | ||
* ###### Preview | ||
* ###### Size | ||
* ###### Title | ||
* ###### Word Count | ||
* ###### Url | ||
* ##### SearchInfo | ||
* ###### TotalHits | ||
* #### Request ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace CreepysinStudios.WikiDotNet | ||
{ | ||
/// <summary> | ||
/// A class that contains information about a Wikipedia search. Currently only contains an int for the total number of | ||
/// results. | ||
/// </summary> | ||
public class SearchInfo | ||
{ | ||
/// <summary> | ||
/// How many hits did the search return (in total, including those not shown) | ||
/// </summary> | ||
// ReSharper disable once StringLiteralTypo | ||
[JsonProperty("totalhits")] public int TotalHits; | ||
|
||
private SearchInfo() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace CreepysinStudios.WikiDotNet | ||
{ | ||
/// <summary> | ||
/// A class that represents a Wikipedia API warning. Often returned when invalid parameters/arguments are passed to the | ||
/// Wikipedia API | ||
/// </summary> | ||
// ReSharper disable once ClassCannotBeInstantiated | ||
public sealed class Warning | ||
{ | ||
/// <summary> | ||
/// What warning code does this this warning correspond to | ||
/// </summary> | ||
[JsonProperty("code")] public readonly string Code; | ||
|
||
/// <summary> | ||
/// What Wikipedia module gave this warning | ||
/// </summary> | ||
[JsonProperty("module")] public readonly string Module; | ||
|
||
/// <summary> | ||
/// Information about this warning | ||
/// </summary> | ||
[JsonProperty("*")] public readonly string Text; | ||
|
||
private Warning() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=settingclasses/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace CreepysinStudios.WikiDotNet | ||
{ | ||
/// <summary> | ||
/// Contains an array of <see cref="WikiSearchResult" />s and a <see cref="SearchInfo" /> | ||
/// </summary> | ||
// ReSharper disable once ClassCannotBeInstantiated | ||
public sealed class WikiSearchQuery | ||
{ | ||
/// <summary> | ||
/// A read-only field that contains information such as the total amount of hits the search returned | ||
/// </summary> | ||
// ReSharper disable once StringLiteralTypo | ||
[JsonProperty("searchinfo")] public readonly SearchInfo SearchInfo; | ||
|
||
/// <summary> | ||
/// An array of results returned from the wikipedia servers | ||
/// </summary> | ||
[JsonProperty("search")] public readonly WikiSearchResult[] SearchResults; | ||
|
||
private WikiSearchQuery() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,72 @@ | ||
#region | ||
|
||
using System; | ||
using System.Net.Http; | ||
using Newtonsoft.Json; | ||
|
||
#endregion | ||
|
||
namespace CreepysinStudios.WikiDotNet | ||
{ | ||
/// <summary> | ||
/// A class that contains an array of <see cref="WikiSearchResult" />, returned from the Wikipedia servers | ||
/// An object returned by the Wikipedia API that contains a <see cref="WikiSearchQuery" /> and <see cref="RequestId" /> | ||
/// </summary> | ||
//TODO: Add Error and warning class in case | ||
// ReSharper disable once ClassCannotBeInstantiated | ||
public sealed class WikiSearchResponse | ||
{ | ||
/// <summary> | ||
/// The Json string from which the results were taken | ||
/// Any errors returned with the request, or <see langword="null" /> if there weren't any | ||
/// </summary> | ||
public readonly string JsonResult; | ||
[JsonProperty("errors")] public readonly Error[] Errors; | ||
|
||
/// <summary> | ||
/// The response message from which the <see cref="SearchResults" /> and <see cref="JsonResult" /> are parsed | ||
/// The Query that the search returned | ||
/// </summary> | ||
public readonly HttpResponseMessage ResponseMessage; | ||
[JsonProperty("query")] public readonly WikiSearchQuery Query; | ||
|
||
/// <summary> | ||
/// An array of results returned from the wikipedia servers | ||
/// The Request ID that was passed during the request | ||
/// </summary> | ||
public readonly WikiSearchResult[] SearchResults; | ||
// ReSharper disable once StringLiteralTypo | ||
[JsonProperty("requestid")] public readonly string RequestId; | ||
|
||
/// <summary> | ||
/// A constructor that creates a new <see cref="WikiSearchResponse" /> | ||
/// The Wikipedia server that this request was served by | ||
/// </summary> | ||
/// <param name="jsonResult">The Json string used to parse the search results</param> | ||
/// <param name="responseMessage">The <see cref="HttpResponseMessage" /> that was returned from the server</param> | ||
/// <param name="searchResults">An array of parsed search results</param> | ||
internal WikiSearchResponse(string jsonResult, | ||
HttpResponseMessage responseMessage, WikiSearchResult[] searchResults) | ||
// ReSharper disable once StringLiteralTypo | ||
[JsonProperty("servedby")] public readonly string ServedBy; | ||
|
||
/// <summary> | ||
/// The time at which the Wikipedia server received the search request | ||
/// </summary> | ||
// ReSharper disable once StringLiteralTypo | ||
[JsonProperty("curtimestamp")] public readonly DateTime Timestamp; | ||
|
||
/// <summary> | ||
/// Any warnings returned with the request, or <see langword="null" /> if there weren't any | ||
/// </summary> | ||
[JsonProperty("warnings")] public readonly Warning[] Warnings; | ||
|
||
private WikiSearchResponse() | ||
{ | ||
JsonResult = jsonResult ?? throw new ArgumentNullException(nameof(jsonResult)); | ||
SearchResults = searchResults ?? throw new ArgumentNullException(nameof(searchResults)); | ||
ResponseMessage = responseMessage ?? throw new ArgumentNullException(nameof(responseMessage)); | ||
} | ||
|
||
/// <summary> | ||
/// Was this request successful, or were there errors? | ||
/// </summary> | ||
public bool WasSuccessful | ||
{ | ||
get | ||
{ | ||
//If our errors and warnings arrays are null, we know this request was successful | ||
if (Errors == null && Warnings == null) return true; | ||
|
||
//If our arrays aren't null and their length is not zero, return false | ||
if (Warnings != null && Warnings.Length != 0) return false; | ||
if (Errors != null && Errors.Length != 0) return false; | ||
|
||
return true; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.