-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not dispose client after file download.
- Loading branch information
1 parent
90d57cc
commit 6f450ea
Showing
6 changed files
with
614 additions
and
142 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
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
204 changes: 204 additions & 0 deletions
204
csharp/Squidex.ClientLibrary/CodeGeneration/File.liquid
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,204 @@ | ||
//---------------------- | ||
// <auto-generated> | ||
// Generated using the NSwag toolchain v{{ ToolchainVersion }} (http://NSwag.org) | ||
// </auto-generated> | ||
//---------------------- | ||
|
||
{% if GenerateNullableReferenceTypes -%} | ||
#nullable enable | ||
|
||
{%- endif %} | ||
{% for usage in NamespaceUsages -%} | ||
using {{ usage }}; | ||
{% endfor -%} | ||
|
||
{% template File.Header %} | ||
|
||
namespace {{ Namespace }} | ||
{ | ||
using System = global::System; | ||
|
||
{{ Clients | tab }} | ||
|
||
{% if GenerateContracts -%} | ||
{{ Classes | tab }} | ||
|
||
{%- if RequiresFileParameterType -%} | ||
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")] | ||
public partial class FileParameter | ||
{ | ||
public FileParameter(System.IO.Stream data) | ||
: this (data, null, null) | ||
{ | ||
} | ||
|
||
{%- if GenerateNullableReferenceTypes -%} | ||
public FileParameter(System.IO.Stream data, string? fileName) | ||
{%- else -%} | ||
public FileParameter(System.IO.Stream data, string fileName) | ||
{%- endif -%} | ||
: this (data, fileName, null) | ||
{ | ||
} | ||
|
||
{%- if GenerateNullableReferenceTypes -%} | ||
public FileParameter(System.IO.Stream data, string? fileName, string? contentType) | ||
{%- else -%} | ||
public FileParameter(System.IO.Stream data, string fileName, string contentType) | ||
{%- endif -%} | ||
{ | ||
Data = data; | ||
FileName = fileName; | ||
ContentType = contentType; | ||
} | ||
|
||
public System.IO.Stream Data { get; private set; } | ||
|
||
{%- if GenerateNullableReferenceTypes -%} | ||
public string? FileName { get; private set; } | ||
|
||
public string? ContentType { get; private set; } | ||
{%- else -%} | ||
public string FileName { get; private set; } | ||
|
||
public string ContentType { get; private set; } | ||
{%- endif -%} | ||
} | ||
|
||
{%- endif %} | ||
{%- if GenerateFileResponseClass %} | ||
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")] | ||
public partial class FileResponse : System.IDisposable | ||
{ | ||
{%- if GenerateNullableReferenceTypes -%} | ||
private System.IDisposable? _client; | ||
private System.IDisposable? _response; | ||
{%- else -%} | ||
private System.IDisposable _client; | ||
private System.IDisposable _response; | ||
{%- endif -%} | ||
|
||
public int StatusCode { get; private set; } | ||
|
||
public System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> Headers { get; private set; } | ||
|
||
public System.IO.Stream Stream { get; private set; } | ||
|
||
public bool IsPartial | ||
{ | ||
get { return StatusCode == 206; } | ||
} | ||
|
||
{%- if GenerateNullableReferenceTypes -%} | ||
public FileResponse(int statusCode, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers, System.IO.Stream stream, System.IDisposable? client, System.IDisposable? response) | ||
{%- else -%} | ||
public FileResponse(int statusCode, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers, System.IO.Stream stream, System.IDisposable client, System.IDisposable response) | ||
{%- endif -%} | ||
{ | ||
StatusCode = statusCode; | ||
Headers = headers; | ||
Stream = stream; | ||
_client = client; | ||
_response = response; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Stream.Dispose(); | ||
if (_response != null) | ||
_response.Dispose(); | ||
} | ||
} | ||
|
||
{%- endif %} | ||
{%- if WrapResponses and GenerateResponseClasses %} | ||
{%- for responseClassName in ResponseClassNames %} | ||
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")] | ||
public partial class {{ responseClassName }} | ||
{ | ||
public int StatusCode { get; private set; } | ||
|
||
public System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> Headers { get; private set; } | ||
|
||
public {{ responseClassName }}(int statusCode, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers) | ||
{ | ||
StatusCode = statusCode; | ||
Headers = headers; | ||
} | ||
} | ||
|
||
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")] | ||
public partial class {{ responseClassName }}<TResult> : {{ responseClassName }} | ||
{ | ||
public TResult Result { get; private set; } | ||
|
||
public {{ responseClassName }}(int statusCode, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers, TResult result) | ||
: base(statusCode, headers) | ||
{ | ||
Result = result; | ||
} | ||
} | ||
|
||
{%- endfor %} | ||
{%- endif %} | ||
{%- if GenerateExceptionClasses %} | ||
{%- for exceptionClassName in ExceptionClassNames %} | ||
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")] | ||
public partial class {{ exceptionClassName }} : System.Exception | ||
{ | ||
public int StatusCode { get; private set; } | ||
|
||
{%- if GenerateNullableReferenceTypes -%} | ||
public string? Response { get; private set; } | ||
{%- else -%} | ||
public string Response { get; private set; } | ||
{%- endif -%} | ||
|
||
public System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> Headers { get; private set; } | ||
|
||
{%- if GenerateNullableReferenceTypes -%} | ||
public {{ exceptionClassName }}(string message, int statusCode, string? response, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers, System.Exception? innerException) | ||
{%- else -%} | ||
public {{ exceptionClassName }}(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers, System.Exception innerException) | ||
{%- endif -%} | ||
: base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + ((response == null) ? "(null)" : response.Substring(0, response.Length >= 512 ? 512 : response.Length)), innerException) | ||
{ | ||
StatusCode = statusCode; | ||
Response = response; | ||
Headers = headers; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString()); | ||
} | ||
} | ||
|
||
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")] | ||
public partial class {{ exceptionClassName }}<TResult> : {{ exceptionClassName }} | ||
{ | ||
public TResult Result { get; private set; } | ||
|
||
{%- if GenerateNullableReferenceTypes -%} | ||
public {{ exceptionClassName }}(string message, int statusCode, string? response, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers, TResult result, System.Exception? innerException) | ||
{%- else -%} | ||
public {{ exceptionClassName }}(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers, TResult result, System.Exception innerException) | ||
{%- endif -%} | ||
: base(message, statusCode, response, headers, innerException) | ||
{ | ||
Result = result; | ||
} | ||
} | ||
|
||
{% endfor -%} | ||
{% endif -%} | ||
{%- endif %} | ||
{% if GenerateImplementation -%} | ||
{% if RequiresJsonExceptionConverter -%} | ||
{% template JsonExceptionConverter %} | ||
{% endif -%} | ||
{%- endif %} | ||
|
||
} | ||
|
||
{% template File.Footer %} |
Oops, something went wrong.