-
Notifications
You must be signed in to change notification settings - Fork 39
/
EntityGrpcAgent_cs.hbs
83 lines (76 loc) · 3.89 KB
/
EntityGrpcAgent_cs.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{{! Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef }}
/*
* This file is automatically generated; any changes will be lost.
*/
#nullable enable
#pragma warning disable
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Beef.Entities;
using Beef.Grpc;
using Beef.WebApi;
using {{Root.NamespaceCommon}}.Entities;
using proto = {{Root.NamespaceCommon}}.Grpc.Proto;
{{#ifval Root.RefDataCommonNamespace}}
using RefDataNamespace = {{Root.RefDataCommonNamespace}};
{{/ifval}}
namespace {{Root.NamespaceCommon}}.Grpc
{
/// <summary>
/// Defines the {{{EntityNameSeeComments}}} gRPC agent.
/// </summary>
public partial interface I{{Name}}Agent
{
{{#each GrpcOperations}}
{{#unless @first}}
{{/unless}}
/// <summary>
/// {{{SummaryText}}}
/// </summary>
{{#ifeq Type 'Patch'}}
/// <param name="patchOption">The <see cref="WebApiPatchOption"/>.</param>
{{/ifeq}}
{{#each Parameters}}
/// <param name="{{ArgumentName}}">{{{SummaryText}}}</param>
{{/each}}
/// <param name="requestOptions">The optional <see cref="GrpcRequestOptions"/>.</param>
/// <returns>A <see cref="GrpcAgentResult"/>.</returns>
{{{GrpcAgentOperationTaskReturnType}}} {{Name}}Async({{#each Parameters}}{{ParameterType}} {{ArgumentName}}{{#if IsPagingArgs}} = null{{/if}}, {{/each}}GrpcRequestOptions? requestOptions = null);
{{/each}}
}
/// <summary>
/// Provides the {{{EntityNameSeeComments}}} gRPC agent.
/// </summary>
public partial class {{Name}}Agent : GrpcAgentBase<proto.{{Name}}GrpcService.{{Name}}GrpcServiceClient>, I{{Name}}Agent
{
/// <summary>
/// Initializes a new instance of the <see cref="{{Name}}Agent"/> class.
/// </summary>
/// <param name="args">The <see cref="{{#if Root.AppBasedAgentArgs}}Common.Agents.I{{Root.AppName}}WebApiAgentArgs{{else}}IWebApiAgentArgs{{/if}}"/>.</param>
/// <param name="mapper">The <see cref="IMapper"/>.</param>
public {{Name}}Agent({{#if Root.AppBasedAgentArgs}}Common.Agents.I{{Root.AppName}}WebApiAgentArgs{{else}}IWebApiAgentArgs{{/if}} args, AutoMapper.IMapper mapper) : base(args, mapper) { }
{{#each GrpcOperations}}
/// <summary>
/// {{{SummaryText}}}
/// </summary>
{{#ifeq Type 'Patch'}}
/// <param name="patchOption">The <see cref="WebApiPatchOption"/>.</param>
{{/ifeq}}
{{#each Parameters}}
/// <param name="{{ArgumentName}}">{{{SummaryText}}}</param>
{{/each}}
/// <param name="requestOptions">The optional <see cref="GrpcRequestOptions"/>.</param>
/// <returns>A <see cref="GrpcAgentResult"/>.</returns>
public {{{GrpcAgentOperationTaskReturnType}}} {{Name}}Async({{#each Parameters}}{{ParameterType}} {{ArgumentName}}{{#if IsPagingArgs}} = null{{/if}}, {{/each}}GrpcRequestOptions? requestOptions = null)
{
{{#ifne Parameters.Count 0}}
var __req = new proto.{{Parent.Name}}{{Name}}Request { {{#each Parameters}}{{#unless @first}}, {{/unless}}{{Name}} = {{#if IsValueArg}}Mapper.Map<{{Type}}, proto.{{Type}}>(Check.NotNull(value, nameof(value))){{else}}{{#if IsPagingArgs}}Transformers.PagingArgsToPagingArgsConverter.ConvertToDest(paging!){{else}}{{#if GrpcConverter}}Transformers.{{GrpcConverter}}.ConvertToDest({{ArgumentName}}){{else}}{{#if GrpcMapper}}Mapper.Map<{{Type}}, proto.{{Type}}>({{ArgumentName}}){{else}}{{ArgumentName}}{{/if}}{{/if}}{{/if}}{{/if}}{{/each}} };
{{/ifne}}
return InvokeAsync{{#if GrpcReturnMapper}}<{{GrpcReturnType}}, proto.{{GrpcReturnType}}>{{/if}}((c, o) => c.{{Name}}Async({{#ifne Parameters.Count 0}}__req, {{/ifne}}o), {{#ifne Parameters.Count 0}}__req, {{/ifne}}{{#if HasReturnValue}}{{#if GrpcReturnConverter}}Transformers.{{GrpcReturnConverter}}, {{/if}}{{/if}}requestOptions);
}
{{/each}}
}
}
#pragma warning restore
#nullable restore