Skip to content

Commit f0a6ecf

Browse files
authored
Merge pull request #75 from TorstenDittmann/master
feat(c#): adds code examples
2 parents 6b08d09 + 84111ca commit f0a6ecf

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/SDK/Language/CSharp.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function getParamExample(array $param)
194194
$output .= 'false';
195195
break;
196196
case self::TYPE_STRING:
197-
$output .= "''";
197+
$output .= '""';
198198
break;
199199
case self::TYPE_OBJECT:
200200
$output .= 'new Object()';
@@ -217,7 +217,7 @@ public function getParamExample(array $param)
217217
$output .= ($example) ? 'true' : 'false';
218218
break;
219219
case self::TYPE_STRING:
220-
$output .= "'{$example}'";
220+
$output .= "\"{$example}\"";
221221
break;
222222
}
223223
}
@@ -249,6 +249,12 @@ public function getFiles()
249249
'template' => '/csharp/LICENSE.twig',
250250
'minify' => false,
251251
],
252+
[
253+
'scope' => 'method',
254+
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md',
255+
'template' => '/csharp/docs/example.md.twig',
256+
'minify' => false,
257+
],
252258
[
253259
'scope' => 'default',
254260
'destination' => '/src/Appwrite.sln',
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use {{ spec.title | caseUcfirst }};
2+
3+
Client client = new Client();
4+
5+
{% if method.security|length > 0 %}
6+
client
7+
.SetEndPoint("https://[HOSTNAME_OR_IP]/v1") # Your API Endpoint
8+
{% for node in method.security %}
9+
{% for key,header in node|keys %}
10+
.Set{{header | caseUcfirst}}("{{node[header]["x-appwrite"]["demo"]}}") # {{node[header].description}}
11+
{% endfor %}
12+
{% endfor %};
13+
14+
{% endif %}
15+
{{ service.name | caseUcfirst }} {{ service.name | caseCamel }} = new {{ service.name | caseUcfirst }}(client);
16+
17+
result = {{ service.name | caseCamel }}.{{ method.name | caseCamel }}({% for parameter in method.parameters.all %}{% if parameter.required %}{% if not loop.first %}, {% endif %}{{ parameter | paramExample }}{% endif %}{% endfor %});

0 commit comments

Comments
 (0)