Fix C# examples in documentation

- Fix documentation after C# renames.
- Add missing `partial` in C# class declarations.
- Change `delta` parameter type to `double` in C#.
- Ensure parameters match base declaration.
- Use `$` string interpolation in C#.
- Fix invalid or outdated C# code.
- Changed some examples to follow our style guide more closely.
This commit is contained in:
Raul Santos
2023-01-31 18:21:09 +01:00
parent 8612c12be6
commit 7eb8325180
35 changed files with 295 additions and 278 deletions

View File

@@ -57,7 +57,7 @@
// Perform a POST request. The URL below returns JSON as of writing.
// Note: Don't make simultaneous requests using a single HTTPRequest node.
// The snippet below is provided for reference only.
string body = new JSON().Stringify(new Godot.Collections.Dictionary
string body = new Json().Stringify(new Godot.Collections.Dictionary
{
{ "name", "Godette" }
});
@@ -69,14 +69,14 @@
}
// Called when the HTTP request is completed.
private void HttpRequestCompleted(int result, int responseCode, string[] headers, byte[] body)
private void HttpRequestCompleted(long result, long responseCode, string[] headers, byte[] body)
{
var json = new JSON();
json.Parse(body.GetStringFromUTF8());
var response = json.GetData() as Godot.Collections.Dictionary;
var json = new Json();
json.Parse(body.GetStringFromUtf8());
var response = json.GetData().AsGodotDictionary();
// Will print the user agent string used by the HTTPRequest node (as recognized by httpbin.org).
GD.Print((response["headers"] as Godot.Collections.Dictionary)["User-Agent"]);
GD.Print((response["headers"].AsGodotDictionary())["User-Agent"]);
}
[/csharp]
[/codeblocks]
@@ -128,9 +128,9 @@
}
// Called when the HTTP request is completed.
private void HttpRequestCompleted(int result, int responseCode, string[] headers, byte[] body)
private void HttpRequestCompleted(long result, long responseCode, string[] headers, byte[] body)
{
if (result != (int)HTTPRequest.Result.Success)
if (result != (long)HTTPRequest.Result.Success)
{
GD.PushError("Image couldn't be downloaded. Try a different image.");
}