Use file-scoped namespaces

This commit is contained in:
Archi
2021-11-10 21:23:24 +01:00
parent 95ad16e26d
commit 1e6ab11d9f
142 changed files with 25006 additions and 25006 deletions

View File

@@ -26,42 +26,42 @@ using ArchiSteamFarm.Web;
using ArchiSteamFarm.Web.Responses;
using Newtonsoft.Json;
namespace ArchiSteamFarm.CustomPlugins.ExamplePlugin {
// This is example class that shows how you can call third-party services within your plugin
// You've always wanted from your ASF to post cats, right? Now is your chance!
// P.S. The code is almost 1:1 copy from the one I use in ArchiBot, you can thank me later
internal static class CatAPI {
private const string URL = "https://aws.random.cat";
namespace ArchiSteamFarm.CustomPlugins.ExamplePlugin;
internal static async Task<string?> GetRandomCatURL(WebBrowser webBrowser) {
if (webBrowser == null) {
throw new ArgumentNullException(nameof(webBrowser));
}
// This is example class that shows how you can call third-party services within your plugin
// You've always wanted from your ASF to post cats, right? Now is your chance!
// P.S. The code is almost 1:1 copy from the one I use in ArchiBot, you can thank me later
internal static class CatAPI {
private const string URL = "https://aws.random.cat";
Uri request = new($"{URL}/meow");
ObjectResponse<MeowResponse>? response = await webBrowser.UrlGetToJsonObject<MeowResponse>(request).ConfigureAwait(false);
if (response == null) {
return null;
}
if (string.IsNullOrEmpty(response.Content.Link)) {
throw new InvalidOperationException(nameof(response.Content.Link));
}
return Uri.EscapeDataString(response.Content.Link);
internal static async Task<string?> GetRandomCatURL(WebBrowser webBrowser) {
if (webBrowser == null) {
throw new ArgumentNullException(nameof(webBrowser));
}
Uri request = new($"{URL}/meow");
ObjectResponse<MeowResponse>? response = await webBrowser.UrlGetToJsonObject<MeowResponse>(request).ConfigureAwait(false);
if (response == null) {
return null;
}
if (string.IsNullOrEmpty(response.Content.Link)) {
throw new InvalidOperationException(nameof(response.Content.Link));
}
return Uri.EscapeDataString(response.Content.Link);
}
#pragma warning disable CA1812 // False positive, the class is used during json deserialization
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
private sealed class MeowResponse {
[JsonProperty(PropertyName = "file", Required = Required.Always)]
internal readonly string Link = "";
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
private sealed class MeowResponse {
[JsonProperty(PropertyName = "file", Required = Required.Always)]
internal readonly string Link = "";
[JsonConstructor]
private MeowResponse() { }
}
#pragma warning restore CA1812 // False positive, the class is used during json deserialization
[JsonConstructor]
private MeowResponse() { }
}
#pragma warning restore CA1812 // False positive, the class is used during json deserialization
}