コード例 #1
0
ファイル: CatAPI.cs プロジェクト: tangli12/ouuse
        internal static async Task <string> GetRandomCatURL([JetBrains.Annotations.NotNull] WebBrowser webBrowser)
        {
            if (webBrowser == null)
            {
                throw new ArgumentNullException(nameof(webBrowser));
            }

            const string request = URL + "/meow";

            WebBrowser.ObjectResponse <MeowResponse> response = await webBrowser.UrlGetToJsonObject <MeowResponse>(request).ConfigureAwait(false);

            if (response?.Content == null)
            {
                return(null);
            }

            if (string.IsNullOrEmpty(response.Content.Link))
            {
                ASF.ArchiLogger.LogNullError(nameof(response.Content.Link));

                return(null);
            }

            return(Uri.EscapeUriString(response.Content.Link));
        }
コード例 #2
0
        internal static async Task <string?> GetRandomCatURL(WebBrowser webBrowser)
        {
            if (webBrowser == null)
            {
                throw new ArgumentNullException(nameof(webBrowser));
            }

            const string request = URL + "/meow";

            WebBrowser.ObjectResponse <MeowResponse>?response = await webBrowser.UrlGetToJsonObject <MeowResponse>(request).ConfigureAwait(false);

            if (response?.Content == null)
            {
                return(null);
            }

            if (string.IsNullOrEmpty(response.Content.Link))
            {
                throw new InvalidOperationException(nameof(response.Content.Link));
            }

            return(Uri.EscapeUriString(response.Content !.Link !));
        }